This repository has been archived by the owner on Sep 21, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 149
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add tests for gemini-facade and fix tests in plugins.js
- Loading branch information
Showing
2 changed files
with
96 additions
and
17 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
'use strict'; | ||
|
||
const EventEmitter = require('events').EventEmitter; | ||
|
||
const _ = require('lodash'); | ||
|
||
const GeminiFacade = require('lib/gemini-facade'); | ||
const RunnerEvents = require('lib/constants/runner-events'); | ||
|
||
describe('gemini-facade', () => { | ||
const sandbox = sinon.sandbox.create(); | ||
|
||
let facade; | ||
let gemini; | ||
let runner; | ||
|
||
beforeEach(() => { | ||
gemini = new EventEmitter(); | ||
runner = new EventEmitter(); | ||
}); | ||
|
||
afterEach(() => sandbox.restore()); | ||
|
||
it('should provide access to passed config', () => { | ||
gemini.config = {rootUrl: 'http://localhost'}; | ||
|
||
facade = new GeminiFacade(gemini); | ||
|
||
assert.equal(facade.config, gemini.config); | ||
}); | ||
|
||
it('should provide access to events', () => { | ||
facade = new GeminiFacade(gemini); | ||
|
||
assert.deepEqual(facade.events, RunnerEvents); | ||
}); | ||
|
||
it('should RUNNER_START event be listen by gemini inst', () => { | ||
sandbox.spy(gemini, 'on'); | ||
|
||
facade = new GeminiFacade(gemini); | ||
|
||
assert.calledWith(gemini.on, 'startRunner'); | ||
}); | ||
|
||
it('should emit RUNNER_START event by facade after it was emitted by gemini inst', () => { | ||
facade = new GeminiFacade(gemini); | ||
|
||
sandbox.spy(facade, 'emit'); | ||
|
||
gemini.emit('startRunner', runner); | ||
|
||
assert.calledWithExactly(facade.emit, 'startRunner', runner); | ||
}); | ||
|
||
it('should passthrough all runner events', () => { | ||
let spy; | ||
|
||
facade = new GeminiFacade(gemini); | ||
|
||
gemini.emit('startRunner', runner); | ||
|
||
_.forEach(RunnerEvents, (event, name) => { | ||
spy = sinon.spy().named(name + ' handler'); | ||
facade.on(event, spy); | ||
|
||
runner.emit(event); | ||
|
||
assert.calledOnce(spy); | ||
}); | ||
}); | ||
}); |
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