Permalink
Browse files

rename view .load to .build

  • Loading branch information...
1 parent deb3ad3 commit 0032f864c90b421cd056e394204ecdeada7535ad @petrjanda committed Apr 30, 2012
Showing with 21 additions and 21 deletions.
  1. +2 −2 lib/denormalizer.js
  2. +1 −1 lib/view.js
  3. +5 −5 spec/denormalizerSpec.js
  4. +13 −13 spec/viewSpec.js
View
@@ -31,7 +31,7 @@ Denormalizer.prototype.registerView = function(view) {
*/
Denormalizer.prototype.updateViews = function(event) {
this.eventsMap[event].forEach(function(view) {
- view.load();
+ view.build();
})
}
@@ -46,5 +46,5 @@ Denormalizer.prototype.build = function(uid) {
throw new Error('View is not registered!');
}
- view.load();
+ view.build();
}
View
@@ -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();
View
@@ -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() {
View
@@ -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) );;
})
@@ -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));
})
@@ -57,7 +57,7 @@ describe('View', function() {
spyOn(storage, 'loadView');
view.uid = '45fsgs45gh';
- view.load(true);
+ view.build(true);
expect(storage.loadView).not.toHaveBeenCalled();
})
@@ -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) );
})
@@ -103,7 +103,7 @@ describe('View', function() {
callback([event]);
});
- view.load();
+ view.build();
expect( view.apply ).toHaveBeenCalledWith( event, jasmine.any(Function) );
})
@@ -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);
})
@@ -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);
})
@@ -157,7 +157,7 @@ describe('View', function() {
fakeGetEvents([event]);
view.snapshots = false;
- view.load();
+ view.build();
expect( storage.storeView ).not.toHaveBeenCalled();
})
@@ -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();
})

0 comments on commit 0032f86

Please sign in to comment.