Multiple Accessor Spies

Convenience methods for creating all automatic accessors of a particular type.

Example

The following demonstrates how Ext Spec can create all store getters as spies.

Production code:
stores: [
    'Groups',
    'Users',
    'Roles'
],

onRolesLoadButtonClick: function () {
    this.getRolesStore().load();
}
Test suite:
it('should load Roles store', function () {
    var store = jasmine.createSpyObject('Roles', ['load']);
    ExtSpec.Jasmine.createStoreSpies(controller);
    // getGroupsStore, getUsersStore and getRolesStore now exist
    controller.getRolesStore.andReturn(store);

    controller.onRolesLoadButtonClick();

    expect(controller.getRolesStore).toHaveBeenCalled();
    expect(store.load).tohHaveBeenCalled();
});

Helpers

createModelSpies

Creates getter spies for all models in instance x:
ExtSpec.Jasmine.createModelSpies(x);
Creates getter spies for models y in instance x:
ExtSpec.Jasmine.createModelSpies(x, y);

createViewSpies

Creates getter spies for all views in instance x:
ExtSpec.Jasmine.createViewSpies(x);
Creates getter spies for views y in instance x:
ExtSpec.Jasmine.createViewSpies(x, y);

createControllerSpies

Creates getter spies for all controllers in instance x:
ExtSpec.Jasmine.createControllerSpies(x);
Creates getter spies for controllers y in instance x:
ExtSpec.Jasmine.createControllerSpies(x, y);

createStoreSpies

Creates getter spies for all stores in instance x:
ExtSpec.Jasmine.createStoreSpies(x);
Creates getter spies for stores y in instance x:
ExtSpec.Jasmine.createStoreSpies(x, y);

createRefSpies

Creates getter spies for all refs in instance x:
ExtSpec.Jasmine.createRefSpies(x);
Creates getter spies for refs y in instance x:
ExtSpec.Jasmine.createRefSpies(x, y);

createConfigSpies

Creates getter and setter spies for all configs in instance x:
ExtSpec.Jasmine.createConfigSpies(x);
Creates getter and setter spies for configs y in instance x:
ExtSpec.Jasmine.createConfigSpies(x, y);

Last edited Feb 16, 2013 at 3:01 AM by Qube, version 3

Comments

No comments yet.