remove rest of async/await in tests

This commit is contained in:
Corey Frang 2018-06-20 15:13:05 -04:00 committed by Michael "Z" Goddard
parent cdd35b5296
commit 2bd946423b
No known key found for this signature in database
GPG key ID: 762CD40DD5349872

View file

@ -17,14 +17,16 @@ tap.test('SoundPlayer', suite => {
}
};
suite.beforeEach(async () => {
suite.beforeEach(() => {
audioContext = new AudioContext();
audioEngine = new AudioEngine(audioContext);
// sound will be 0.1 seconds long
audioContext.DECODE_AUDIO_DATA_RESULT = audioContext.createBuffer(2, 4410, 44100);
audioContext.DECODE_AUDIO_DATA_FAILED = false;
const data = new Uint8Array(44100);
soundPlayer = await audioEngine.decodeSoundPlayer({data});
return audioEngine.decodeSoundPlayer({data}).then(result => {
soundPlayer = result;
});
});
suite.afterEach(() => {
@ -114,15 +116,15 @@ tap.test('SoundPlayer', suite => {
soundPlayer.play();
soundPlayer.finished().then(() => log.push('play 1 finished'));
soundPlayer.connect(audioEngine);
let oldPlayerNode;
const firstPlayNode = soundPlayer.outputNode;
audioContext.$processTo(0.005);
return Promise.resolve()
.then(() => {
audioContext.$processTo(0.005);
t.equal(soundPlayer.outputNode.$state, 'PLAYING');
oldPlayerNode = soundPlayer.outputNode;
soundPlayer.play();
soundPlayer.finished().then(() => log.push('play 2 finished'));
@ -132,10 +134,10 @@ tap.test('SoundPlayer', suite => {
.then(() => {
t.equal(log[0], 'play 1 finished');
t.notEqual(soundPlayer.outputNode, oldPlayerNode, 'created new player node');
t.notEqual(soundPlayer.outputNode, firstPlayNode, 'created new player node');
t.equal(help.engineInputs.length, 2, 'there should be 2 players connected');
t.equal(oldPlayerNode.$state, 'PLAYING');
t.equal(firstPlayNode.$state, 'PLAYING');
t.equal(soundPlayer.outputNode.$state, 'PLAYING');
t.equal(help.engineInputs[0].gain.value, 1, 'old sound connectect to gain node with volume 1');
@ -145,7 +147,7 @@ tap.test('SoundPlayer', suite => {
audioContext.$processTo(audioContext.currentTime + audioEngine.DECAY_TIME + 0.001);
t.equal(soundPlayer.outputNode.$state, 'PLAYING');
t.equal(oldPlayerNode.$state, 'FINISHED');
t.equal(firstPlayNode.$state, 'FINISHED');
t.equal(help.engineInputs[0].gain.value, 0, 'faded old sound to 0');