-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
49 changed files
with
2,397 additions
and
2,502 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,41 @@ | ||
/* eslint-env mocha */ | ||
/* eslint no-unused-expressions: "off" */ | ||
/* eslint-env jest */ | ||
|
||
import chai from 'chai'; | ||
import chaiAsPromised from 'chai-as-promised'; | ||
import sinonChai from 'sinon-chai'; | ||
import configureStore from 'redux-mock-store'; | ||
import DDPClient from './DDPClient'; | ||
|
||
chai.should(); | ||
chai.use(sinonChai); | ||
chai.use(chaiAsPromised); | ||
|
||
describe('Test DDPClient', () => { | ||
beforeEach(function () { | ||
this.ddpClient = new DDPClient(); | ||
let testContext; | ||
|
||
beforeEach(() => { | ||
testContext = {}; | ||
}); | ||
|
||
beforeEach(() => { | ||
testContext.ddpClient = new DDPClient(); | ||
}); | ||
|
||
describe('Given I have a ddp middleware', () => { | ||
beforeEach(function () { | ||
this.middleware = this.ddpClient.middleware(); | ||
this.mockStore = configureStore([ | ||
this.middleware, | ||
beforeEach(() => { | ||
testContext.middleware = testContext.ddpClient.middleware(); | ||
testContext.mockStore = configureStore([ | ||
testContext.middleware, | ||
]); | ||
}); | ||
|
||
it('should accept function as an action', function () { | ||
const store = this.mockStore(); | ||
test('should accept function as an action', () => { | ||
const store = testContext.mockStore(); | ||
store.dispatch((dispatch) => { | ||
dispatch({ | ||
type: 'test_action', | ||
}); | ||
}); | ||
store.getActions().should.have.deep.members([ | ||
expect(store.getActions()).toEqual(expect.arrayContaining([ | ||
{ type: 'test_action' }, | ||
]); | ||
])); | ||
}); | ||
}); | ||
|
||
it('should be ok', function () { | ||
this.ddpClient.should.be.ok; | ||
test('should be ok', () => { | ||
expect(testContext.ddpClient).toBeTruthy(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,42 @@ | ||
/* eslint-env mocha */ | ||
/* eslint no-unused-expressions: "off" */ | ||
/* eslint-env jest */ | ||
|
||
import chai from 'chai'; | ||
import sinon from 'sinon'; | ||
import sinonChai from 'sinon-chai'; | ||
import DDPEmitter from './DDPEmitter'; | ||
|
||
chai.should(); | ||
chai.use(sinonChai); | ||
|
||
describe('Test DDPEmitter', () => { | ||
beforeEach(function () { | ||
this.emitter = new DDPEmitter(); | ||
this.m1 = sinon.spy(); | ||
this.m2 = sinon.spy(); | ||
this.m3 = sinon.spy(); | ||
this.emitter.on('m1', this.m1); | ||
this.emitter.on('m2', this.m2); | ||
this.emitter.on('m2', this.m3); | ||
let testContext; | ||
|
||
beforeEach(() => { | ||
testContext = {}; | ||
}); | ||
|
||
beforeEach(() => { | ||
testContext.emitter = new DDPEmitter(); | ||
testContext.m1 = jest.fn(); | ||
testContext.m2 = jest.fn(); | ||
testContext.m3 = jest.fn(); | ||
testContext.emitter.on('m1', testContext.m1); | ||
testContext.emitter.on('m2', testContext.m2); | ||
testContext.emitter.on('m2', testContext.m3); | ||
}); | ||
|
||
it('should not do anyghing there are no listeners', function () { | ||
this.emitter.emit('mx'); | ||
this.m1.should.not.be.called; | ||
this.m2.should.not.be.called; | ||
this.m3.should.not.be.called; | ||
test('should not do anyghing there are no listeners', () => { | ||
testContext.emitter.emit('mx'); | ||
expect(testContext.m1).not.toBeCalled(); | ||
expect(testContext.m2).not.toBeCalled(); | ||
expect(testContext.m3).not.toBeCalled(); | ||
}); | ||
|
||
it('should trigger one listener', function () { | ||
this.emitter.emit('m1'); | ||
this.m1.should.be.called; | ||
this.m2.should.not.be.called; | ||
this.m3.should.not.be.called; | ||
test('should trigger one listener', () => { | ||
testContext.emitter.emit('m1'); | ||
expect(testContext.m1).toBeCalled(); | ||
expect(testContext.m2).not.toBeCalled(); | ||
expect(testContext.m3).not.toBeCalled(); | ||
}); | ||
|
||
it('should trigger two listeners', function () { | ||
this.emitter.emit('m2'); | ||
this.m1.should.not.be.called; | ||
this.m2.should.be.called; | ||
this.m3.should.be.called; | ||
test('should trigger two listeners', () => { | ||
testContext.emitter.emit('m2'); | ||
expect(testContext.m1).not.toBeCalled(); | ||
expect(testContext.m2).toBeCalled(); | ||
expect(testContext.m3).toBeCalled(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.