Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
hankhsiao committed Aug 31, 2015
1 parent c4430c9 commit 4c1fdbd
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions tests/unit/subscribe.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,12 +186,21 @@ describe('subscribe', function () {
ee.emit('resize', {foo: 'foo'});
});

it('scroll should be triggered by window scroll with scroll information', function (done) {
var subscription = subscribe('scroll', function (e, syntheticEvent) {
it.only('scroll should be triggered by window scroll with scroll information', function (done) {
// the first one subscription should get scroll info as well, because information is global
var subscription1 = subscribe('scroll', function (e, syntheticEvent) {
expect(e.foo).equal('foo');
expect(syntheticEvent.type).equal('scroll');
expect(syntheticEvent.scroll.top).equal(10);
subscription.unsubscribe();
subscription1.unsubscribe();
}, {enableScrollInfo: false});

// the second one request scroll info, which should dominate.
var subscription2 = subscribe('scroll', function (e, syntheticEvent) {
expect(e.foo).equal('foo');
expect(syntheticEvent.type).equal('scroll');
expect(syntheticEvent.scroll.top).equal(10);
subscription2.unsubscribe();
done();
}, {enableScrollInfo: true});

Expand Down

0 comments on commit 4c1fdbd

Please sign in to comment.