-
Notifications
You must be signed in to change notification settings - Fork 53
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
8 changed files
with
343 additions
and
302 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
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,66 @@ | ||
import assert from 'power-assert' | ||
import container from '../src/container' | ||
|
||
describe('container', () => { | ||
context('when YouTube is not ready', () => { | ||
describe('#register', () => { | ||
it('should add a callback to scripts', () => { | ||
const length = container.scripts.length | ||
container.register(() => {}) | ||
assert.equal(container.scripts.length, length + 1) | ||
}) | ||
}) | ||
|
||
after(() => { | ||
container.scripts = [] | ||
}) | ||
}) | ||
|
||
context('when YouTube is ready', () => { | ||
before(() => { | ||
container.YT = { | ||
Player () {} | ||
} | ||
container.Vue = { | ||
nextTick (callback) { | ||
callback() | ||
} | ||
} | ||
}) | ||
|
||
describe('#run', () => { | ||
it('should call calbacks and pass YT.Player to its scripts', () => { | ||
const spy = sinon.spy() | ||
container.scripts = [spy] | ||
container.run() | ||
assert.ok(spy.calledWith(container.YT)) | ||
}) | ||
|
||
it('should remove elements from scripts', () => { | ||
container.scripts.push(() => {}) | ||
container.run() | ||
assert.equal(container.scripts.length, 0) | ||
}) | ||
|
||
afterEach(() => { | ||
container.scripts = [] | ||
}) | ||
}) | ||
|
||
describe('#register', () => { | ||
it('should call callback', () => { | ||
sinon.spy(container.Vue, 'nextTick') | ||
const callbackSpy = sinon.spy() | ||
container.register(callbackSpy) | ||
assert.ok(container.Vue.nextTick.called) | ||
assert.ok(callbackSpy.called) | ||
container.Vue.nextTick.restore() | ||
}) | ||
}) | ||
}) | ||
|
||
after(() => { | ||
delete container.YT | ||
delete container.Vue | ||
}) | ||
}) |
Oops, something went wrong.