diff --git a/src/tests/Abstract.test.ts b/src/tests/Abstract.test.ts index fbebd2c..72328f8 100644 --- a/src/tests/Abstract.test.ts +++ b/src/tests/Abstract.test.ts @@ -30,7 +30,7 @@ describe('Abstract implementation', () => { mockSound.mute = false; }); - it('allows `set` and `get`', () => { + it('allows `set` and `get`', async () => { expect(mockSound.mute).toBe(false); mockSound.mute = true; expect(mockSound.mute).toBe(true); @@ -40,7 +40,7 @@ describe('Abstract implementation', () => { it.todo('sets gain to 0 when muted'); it.todo('sets gain to volume when un-muted'); - it('fades to new value', () => { + it('fades to new value', async () => { const mockOptions: SoundConfig = { volume: 0.6, fadeMs: 100, @@ -105,24 +105,24 @@ describe('Abstract implementation', () => { mockSound.mute = false; }); - it('allows `set` and `get`', () => { + it('allows `set` and `get`', async () => { const mockVolume = 0.4; mockSound.volume = mockVolume; expect(mockSound.volume).toBe(mockVolume); }); - it('restricts value to a minimum of `0`', () => { + it('restricts value to a minimum of `0`', async () => { mockSound.volume = -2; expect(mockSound.volume).toBe(0); }); - it('restricts value to a maximum of `1`', () => { + it('restricts value to a maximum of `1`', async () => { mockSound.volume = 2; expect(mockSound.volume).toBe(1); }); - it('sets value on `gain`', () => { + it('sets value on `gain`', async () => { const oldValue = mockSound.volume; const newValue = 0.6; const {currentTime} = defaultContext; @@ -145,7 +145,7 @@ describe('Abstract implementation', () => { expect(spyGainRamp).toBeCalledWith(newValue, currentTime); }); - it('does not set value on gain if muted', () => { + it('does not set value on gain if muted', async () => { const mockVolume = 0.2; const spyGainCancel = vi.spyOn( @@ -179,7 +179,7 @@ describe('Abstract implementation', () => { expect(spyGainRamp).not.toBeCalledTimes(2); }); - it('fades to new volume', () => { + it('fades to new volume', async () => { const mockOptions: SoundConfig = { volume: 0.6, fadeMs: 100, diff --git a/src/tests/Earwurm.test.ts b/src/tests/Earwurm.test.ts index 537341d..18619e9 100644 --- a/src/tests/Earwurm.test.ts +++ b/src/tests/Earwurm.test.ts @@ -28,7 +28,7 @@ describe('Earwurm component', () => { }); describe('initialization', () => { - it('is initialized with default values', () => { + it('is initialized with default values', async () => { expect(mockManager).toBeInstanceOf(Earwurm); // Class static properties diff --git a/src/tests/Stack.test.ts b/src/tests/Stack.test.ts index 4ba6ef3..5309601 100644 --- a/src/tests/Stack.test.ts +++ b/src/tests/Stack.test.ts @@ -27,7 +27,7 @@ describe('Stack component', () => { }); describe('initialization', () => { - it('is initialized with default values', () => { + it('is initialized with default values', async () => { expect(mockStack).toBeInstanceOf(Stack); // Class static properties diff --git a/src/tests/helpers.test.ts b/src/tests/helpers.test.ts index 368761a..ac3e821 100644 --- a/src/tests/helpers.test.ts +++ b/src/tests/helpers.test.ts @@ -13,7 +13,7 @@ describe('Helpers', () => { const mockContext = new AudioContext(); describe('getErrorMessage()', () => { - it('returns message from basic object', () => { + it('returns message from basic object', async () => { const mockError = { message: 'foo', }; @@ -23,7 +23,7 @@ describe('Helpers', () => { expect(result).toBe(mockError.message); }); - it('returns message from Error', () => { + it('returns message from Error', async () => { const mockMessage = 'Foo'; const mockError = new Error(mockMessage, { cause: 'bar', @@ -34,7 +34,7 @@ describe('Helpers', () => { expect(result).toBe(mockMessage); }); - it('returns stringified result when unknown', () => { + it('returns stringified result when unknown', async () => { const mockError = ['foo', true, {bar: false}, null]; const result = getErrorMessage(mockError); @@ -67,7 +67,7 @@ describe('Helpers', () => { }); describe('linearRamp()', () => { - it('transitions to the specified value', () => { + it('transitions to the specified value', async () => { const mockAudioParam = new AudioParam(); const spyCancel = vi.spyOn(mockAudioParam, 'cancelScheduledValues'); @@ -104,7 +104,7 @@ describe('Helpers', () => { }); describe('scratchBuffer()', () => { - it('creates a short silent AudioBuffer', () => { + it('creates a short silent AudioBuffer', async () => { const result = scratchBuffer(mockContext); expect(result).toBeInstanceOf(AudioBuffer); @@ -120,7 +120,7 @@ describe('Helpers', () => { vi.advanceTimersToNextTimer(); }); - it('resumes AudioContext state', () => { + it('resumes AudioContext state', async () => { const spyCreateBuffer = vi.spyOn(mockContext, 'createBuffer'); const spyResume = vi.spyOn(mockContext, 'resume'); @@ -147,7 +147,7 @@ describe('Helpers', () => { expect(spySourceStart).toBeCalledTimes(1); }); - it('calls onEnded after interaction event', () => { + it('calls onEnded after interaction event', async () => { vi.spyOn( AudioBufferSourceNode.prototype, 'addEventListener', diff --git a/src/tests/utilities.test.ts b/src/tests/utilities.test.ts index 1cd0d31..074171e 100644 --- a/src/tests/utilities.test.ts +++ b/src/tests/utilities.test.ts @@ -12,12 +12,12 @@ import { describe('Utilities', () => { describe('Array', () => { describe('arrayOfLength()', () => { - it('returns an empty array by default', () => { + it('returns an empty array by default', async () => { const result = arrayOfLength(); expect(result).toStrictEqual([]); }); - it('returns an array of incremented index values', () => { + it('returns an array of incremented index values', async () => { const mockLength = 6; const result = arrayOfLength(mockLength); @@ -27,7 +27,7 @@ describe('Utilities', () => { }); describe('arrayShallowEquals()', () => { - it('returns `true` when matching', () => { + it('returns `true` when matching', async () => { const result = arrayShallowEquals( [true, false, null, undefined, 0, 1, 'end'], [true, false, null, undefined, 0, 1, 'end'], @@ -35,7 +35,7 @@ describe('Utilities', () => { expect(result).toBe(true); }); - it('returns `false` when at least one value is unmatched', () => { + it('returns `false` when at least one value is unmatched', async () => { const result = arrayShallowEquals([true, false], [false, true]); expect(result).toBe(false); }); @@ -44,32 +44,32 @@ describe('Utilities', () => { describe('Numbers', () => { describe('assertNumber()', () => { - it('accepts an integer', () => { + it('accepts an integer', async () => { const result = assertNumber(123); expect(result).toBe(true); }); - it('accepts a float', () => { + it('accepts a float', async () => { const result = assertNumber(123.456); expect(result).toBe(true); }); - it('does not allow a bigint', () => { + it('does not allow a bigint', async () => { const result = assertNumber(1000n); expect(result).toBe(false); }); - it('does not allow NaN', () => { + it('does not allow NaN', async () => { const result = assertNumber(NaN); expect(result).toBe(false); }); - it('does not allow Infinity', () => { + it('does not allow Infinity', async () => { const result = assertNumber(Infinity); expect(result).toBe(false); }); - it('does not allow other non-numnber types', () => { + it('does not allow other non-numnber types', async () => { expect(assertNumber(true)).toBe(false); expect(assertNumber(false)).toBe(false); expect(assertNumber({one: 1})).toBe(false); @@ -79,21 +79,21 @@ describe('Utilities', () => { }); describe('clamp()', () => { - it('returns preference', () => { + it('returns preference', async () => { const mockArgs: Parameters = [1, 10, 100]; const result = clamp(...mockArgs); expect(result).toBe(10); }); - it('returns min', () => { + it('returns min', async () => { const mockArgs: Parameters = [10, 1, 100]; const result = clamp(...mockArgs); expect(result).toBe(10); }); - it('returns max', () => { + it('returns max', async () => { const mockArgs: Parameters = [1, 100, 10]; const result = clamp(...mockArgs); @@ -102,24 +102,24 @@ describe('Utilities', () => { }); describe('progressPercentage()', () => { - it('returns percentage integer', () => { + it('returns percentage integer', async () => { const result = progressPercentage(6, 20); expect(result).toBe(30); }); - it('round down floating-point result', () => { + it('round down floating-point result', async () => { const result = progressPercentage(12, 345); // Before Math.floor(), result should be: // 3.4782608695652173 expect(result).toBe(3); }); - it('protects against NaN', () => { + it('protects against NaN', async () => { const result = progressPercentage(0, 0); expect(result).toBe(0); }); - it('protects against Infinity', () => { + it('protects against Infinity', async () => { const result = progressPercentage(2, 0); expect(result).toBe(0); }); @@ -128,14 +128,14 @@ describe('Utilities', () => { describe('Time', () => { describe('msToSec()', () => { - it('converts to seconds', () => { + it('converts to seconds', async () => { const result = msToSec(1234); expect(result).toBe(1.234); }); }); describe('secToMs()', () => { - it('converts to milliseconds', () => { + it('converts to milliseconds', async () => { const result = secToMs(5.678); expect(result).toBe(5678); });