1

In ExtJs application to make getStore work controllers, models and stores are added in Application.js. But for testing with siesta, I can't make any changes in Application.js.

Calling Ext.getStore(storeId) directly is returning undefined. I have tried by adding model in preload, but it doesn't help.

What should I do for this?

-------------------------Code in the testFile AnalysisController.t.js ---------------------

StartTest(function(t){

var testStore = Ext.getStore('Nm.store.analysis.TestStore'); //testStore is undefined

});

-------------------------Code in testModel.js-------------------------

Ext.define('Nm.model.analysis.TestModel', 
    {
    extend: 'Ext.data.Model',    
    fields: [ 
            {name:'lastName',type:'string'},
            {name:'age',type:'int'},
            {name:'relationDescription',type:'string'},
            {name:'dateOfBirth',type:'date',dateFormat: 'm-D-Y'}
            ]
    });

-------------------------Code in testStore.js-------------------------

Ext.define('Nm.store.analysis.TestStore',{
    extend : 'Ext.data.Store',
    requires: ['Nm.model.analysis.TestModel'],
    model : 'Nm.model.analysis.TestModel'
});

-------------------------Code in harness file testIndex.js----------------

var Harness = Siesta.Harness.Browser.ExtJS;

Harness.configure({
    title       : 'Samples',
    loaderPath  : { 'Nm' : 'app' },
    preload : [
        "http://cdn.sencha.io/ext/gpl/4.2.0/resources/css/ext-all.css",
        "http://cdn.sencha.io/ext/gpl/4.2.0/ext-all-debug.js"
    ]

});

Harness.start({
        group               : 'Controller',
        items               : [
            'test/AnalysisController.t.js'
        ]}
);
CD..
  • 72,281
  • 25
  • 154
  • 163
Ankita
  • 199
  • 3
  • 18
  • As @Marlo said, store should be registered but for that you don't need to register it explicitly. Specify storeId in your store with some value then store will automatically gets registered. – Bala Nov 15 '14 at 08:33

3 Answers3

0

to use Ext.getStore() you have to register the store I think.

plz read

  • Ext.getStore() is working fine in application, but I am facing problem only while calling it directly from test class. – Ankita Nov 17 '14 at 03:51
0

Check if Ext is defined in your test file. Although Siesta supports Ext, the variable Ext is not defined by default. The simplest way to do this is just by adding the following at the top of your test:

var Ext = test.global.Ext;
David Millar
  • 1,858
  • 1
  • 14
  • 23
0

To load a "global" store via Ext.getStore(), it must be registered in the application.

To do that, ensure it is added to the stores array in your main app class

Ext.application({
    extend: 'Ext.app.Application',
    stores: [ add global store classes here ]
});
jenson-button-event
  • 18,101
  • 11
  • 89
  • 155