mirror of
https://github.com/darkwire/darkwire.io.git
synced 2025-07-19 11:02:58 +00:00
54 lines
1.0 KiB
JavaScript
54 lines
1.0 KiB
JavaScript
import assert from 'assert';
|
|
import AudioHandler from '../../src/js/audio.js';
|
|
import sinon from 'sinon';
|
|
|
|
describe('Audio', () => {
|
|
|
|
describe('playing sounds', () => {
|
|
|
|
describe('when window.Audio is supported', () => {
|
|
|
|
describe('when sound is enabled', () => {
|
|
let playStub;
|
|
|
|
before(() => {
|
|
let audio = new AudioHandler();
|
|
playStub = sinon.stub(audio._beep, 'play');
|
|
audio.play();
|
|
});
|
|
|
|
after(() => {
|
|
playStub.reset();
|
|
});
|
|
|
|
it('should play sounds', () => {
|
|
assert(playStub.called);
|
|
});
|
|
});
|
|
|
|
describe('sound is not enabled', () => {
|
|
let playStub;
|
|
|
|
before(() => {
|
|
let audio = new AudioHandler();
|
|
audio.soundEnabled = false;
|
|
playStub = sinon.stub(audio._beep, 'play');
|
|
audio.play();
|
|
});
|
|
|
|
after(() => {
|
|
playStub.reset();
|
|
});
|
|
|
|
it('should not play sounds', () => {
|
|
assert(playStub.notCalled);
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|