Skip to content

Commit

Permalink
rename view .load to .build
Browse files Browse the repository at this point in the history
  • Loading branch information
Petr Janda committed Apr 30, 2012
1 parent deb3ad3 commit 0032f86
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 21 deletions.
4 changes: 2 additions & 2 deletions lib/denormalizer.js
Expand Up @@ -31,7 +31,7 @@ Denormalizer.prototype.registerView = function(view) {
*/
Denormalizer.prototype.updateViews = function(event) {
this.eventsMap[event].forEach(function(view) {
view.load();
view.build();
})
}

Expand All @@ -46,5 +46,5 @@ Denormalizer.prototype.build = function(uid) {
throw new Error('View is not registered!');
}

view.load();
view.build();
}
2 changes: 1 addition & 1 deletion lib/view.js
Expand Up @@ -51,7 +51,7 @@ module.exports = View = function(uid, eventNames) {
* @param {Boolean} Let it true if snapshots should be skipped.
* @param {Function} Callback function to be triggered when ready.
*/
View.prototype.load = function(reload, callback) {
View.prototype.build = function(reload, callback) {
var self = this,
storage = Storage.createStorage();

Expand Down
10 changes: 5 additions & 5 deletions spec/denormalizerSpec.js
Expand Up @@ -38,28 +38,28 @@ describe('Denormalizer', function() {
})

describe('#updateViews', function() {
it('should trigger .load function for all registered views', function() {
it('should trigger .build function for all registered views', function() {
var view = new View('foo', ['bar', 'baz']);
spyOn(view, 'load');
spyOn(view, 'build');

denormalizer.registerView(view);

denormalizer.updateViews('baz');

expect(view.load).toHaveBeenCalled();
expect(view.build).toHaveBeenCalled();
})
})

describe('#build', function() {
it('should trigger .load function for the view if exists', function() {
var view = new View('foo', ['bar', 'baz']);
spyOn(view, 'load');
spyOn(view, 'build');

denormalizer.registerView(view);

denormalizer.build('foo');

expect(view.load).toHaveBeenCalled();
expect(view.build).toHaveBeenCalled();
})

it('should throw exception if view doesnt exist', function() {
Expand Down
26 changes: 13 additions & 13 deletions spec/viewSpec.js
Expand Up @@ -31,13 +31,13 @@ describe('View', function() {
})
})

describe('.load', function() {
describe('.build', function() {

describe('with disabled storage', function() {
it('should directly call getEventsByName', function() {
view.snapshots = false;

view.load();
view.build();

expect(repository.getEventsByName).toHaveBeenCalledWith( 'foo', 1, jasmine.any(Function) );;
})
Expand All @@ -47,7 +47,7 @@ describe('View', function() {
spyOn(storage, 'loadView');
view.uid = '45fsgs45gh';

view.load();
view.build();

expect(storage.loadView).toHaveBeenCalledWith('45fsgs45gh', jasmine.any(Function));
})
Expand All @@ -57,7 +57,7 @@ describe('View', function() {
spyOn(storage, 'loadView');
view.uid = '45fsgs45gh';

view.load(true);
view.build(true);

expect(storage.loadView).not.toHaveBeenCalled();
})
Expand All @@ -76,20 +76,20 @@ describe('View', function() {
})

it('should store data to the view', function() {
view.load();
view.build();

expect(view.data).toEqual({ foo : 'bar' })
})

it('should store data to the view', function() {
view.load();
view.build();

expect(view.lastEvent).toEqual(1325721336913);
})


it('should load events increment data from repository', function() {
view.load();
view.build();

expect(repository.getEventsByName).toHaveBeenCalledWith( 'foo', 1325721336914, jasmine.any(Function) );
})
Expand All @@ -103,7 +103,7 @@ describe('View', function() {
callback([event]);
});

view.load();
view.build();

expect( view.apply ).toHaveBeenCalledWith( event, jasmine.any(Function) );
})
Expand All @@ -130,15 +130,15 @@ describe('View', function() {
it( 'should store view if events increment was loaded', function() {
fakeGetEvents([event]);

view.load();
view.build();

expect( storage.storeView ).toHaveBeenCalledWith(view);
})

it( 'should store view if events increment was loaded', function() {
fakeGetEvents([event]);

view.load();
view.build();

expect( storage.purgeView ).toHaveBeenCalledWith(view.uid);
})
Expand All @@ -148,7 +148,7 @@ describe('View', function() {
it( 'should not store view if no events were loaded', function() {
fakeGetEvents([]);

view.load();
view.build();

expect( storage.storeView ).not.toHaveBeenCalledWith(view);
})
Expand All @@ -157,7 +157,7 @@ describe('View', function() {
fakeGetEvents([event]);
view.snapshots = false;

view.load();
view.build();

expect( storage.storeView ).not.toHaveBeenCalled();
})
Expand All @@ -167,7 +167,7 @@ describe('View', function() {
this.handler = function() {}
spyOn( this, 'handler')

view.load(this.handler);
view.build(this.handler);

expect( this.handler ).toHaveBeenCalled();
})
Expand Down

0 comments on commit 0032f86

Please sign in to comment.