Skip to content

Commit

Permalink
test(dialog audio vocal synth): rewrite test to manually updates for …
Browse files Browse the repository at this point in the history
…more consistent results
  • Loading branch information
seleb committed Jul 10, 2022
1 parent 1a879a9 commit 943511c
Showing 1 changed file with 69 additions and 88 deletions.
157 changes: 69 additions & 88 deletions src/dialog audio vocal synth.test.js
Original file line number Diff line number Diff line change
@@ -1,138 +1,119 @@
import { delay, evaluate, press, start, waitForBlip, walkToCat } from './test/bitsy';
import { delay, evaluate, start, startDialog } from './test/bitsy';

test('dialog audio vocal synth', async () => {
await start({
hacks: ['dialog audio vocal synth'],
});
await walkToCat();
await evaluate(() => {
window.Math.random = () => 0;
window.log = [];
window.setInterval(() => {
async function capture() {
await evaluate(() => {
window.log = window.log || [];
window.log.push([
window.hacks.dialog_audio_vocal_synth.Glottis.isTouched,
window.hacks.dialog_audio_vocal_synth.Glottis.UITenseness.toFixed(1),
window.hacks.dialog_audio_vocal_synth.Tract.velumTarget.toFixed(1),
window.hacks.dialog_audio_vocal_synth.Glottis.loudness.toFixed(1),
window.hacks.dialog_audio_vocal_synth.Glottis.vibratoAmount.toFixed(1),
window.hacks.dialog_audio_vocal_synth.Glottis.UIFrequency.toFixed(0),
Object.values(window.hacks.dialog_audio_vocal_synth.Tract.targetDiameter)
.map(i => i.toFixed(1))
.join(','),
Object.values(window.hacks.dialog_audio_vocal_synth.Tract.diameter)
.map(i => i.toFixed(1))
.join(','),
window.hacks.dialog_audio_vocal_synth.Glottis.loudness.toFixed(1),
window.hacks.dialog_audio_vocal_synth.Glottis.vibratoAmount.toFixed(1),
window.hacks.dialog_audio_vocal_synth.Glottis.UIFrequency.toFixed(1),
]);
}, 250);
});
}
async function advance() {
await evaluate(() => window.updateSystem()); // manual update
}
async function advanceAndCapture() {
await delay(10);
await advance();
await delay(10);
await advance();
await delay(10);
await advance();
await delay(10);
await advance();
await capture();
}

await start({
title: '',
hacks: ['dialog audio vocal synth'],
});
await press('ArrowRight'); // talk to cat
await waitForBlip();
await delay(1500);
await press('ArrowRight'); // end dialog
await press('ArrowRight'); // talk to cat
await waitForBlip();
await press('ArrowRight'); // complete dialog
// disable rng
await evaluate(() => {
window.Math.random = () => 0.5;
});
await delay(1000); // allow lerps to settle

await evaluate(() => window.clearInterval(window.updateInterval)); // cancel update loop
await capture();
await startDialog('qwer');
await advanceAndCapture();
await advanceAndCapture();
await advanceAndCapture();
await advanceAndCapture();
await advanceAndCapture();
expect(await evaluate(() => window.log)).toMatchInlineSnapshot(`
Array [
Array [
false,
"0.6",
"1.0",
"0.6,0.6,0.6,0.6,0.6,0.6,0.6,1.1,1.1,1.1,1.1,1.1,1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5",
"0.6,0.6,0.6,0.6,0.6,0.6,0.6,1.1,1.1,1.1,1.1,1.1,1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5",
"0.4",
"0.0",
"426.5",
],
Array [
false,
"0.6",
"1.0",
"440",
"0.6,0.6,0.6,0.6,0.6,0.6,0.6,1.1,1.1,1.1,1.1,1.1,1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5",
"0.6,0.6,0.6,0.6,0.6,0.6,0.6,1.1,1.1,1.1,1.1,1.1,1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5",
"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