-
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add tests for ChannelStore and channel singletons
- Loading branch information
Showing
2 changed files
with
68 additions
and
0 deletions.
There are no files selected for viewing
56 changes: 56 additions & 0 deletions
56
packages/mixer-connection/src/lib/__tests__/channel-singletons.spec.ts
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,56 @@ | ||
import { SoundcraftUI } from '../soundcraft-ui'; | ||
|
||
describe('Channel Store Singletons', () => { | ||
let conn: SoundcraftUI; | ||
|
||
beforeEach(() => { | ||
conn = new SoundcraftUI('0.0.0.0'); | ||
}); | ||
|
||
// Note: comparing class instances with toBe() directly doesn't work because of circular structure errors. | ||
// This is why we used toBe(true) as a workaround. | ||
|
||
describe('should create objects only once and retrieve them from the ChannelStore', () => { | ||
it('MasterChannel', () => { | ||
const ch1 = conn.master.player(2); | ||
const ch2 = conn.master.player(2); | ||
expect(ch1 === ch2).toBe(true); | ||
}); | ||
|
||
it('DelayableMasterChannel', () => { | ||
const ch1 = conn.master.input(10); | ||
const ch2 = conn.master.input(10); | ||
expect(ch1 === ch2).toBe(true); | ||
}); | ||
|
||
it('AuxChannel', () => { | ||
const ch1 = conn.aux(2).input(4); | ||
const ch2 = conn.aux(2).input(4); | ||
expect(ch1 === ch2).toBe(true); | ||
}); | ||
|
||
it('FxChannel', () => { | ||
const ch1 = conn.fx(1).input(2); | ||
const ch2 = conn.fx(1).input(2); | ||
expect(ch1 === ch2).toBe(true); | ||
}); | ||
|
||
it('VolumeBus', () => { | ||
const bus1 = conn.volume.headphone(1); | ||
const bus2 = conn.volume.headphone(1); | ||
expect(bus1 === bus2).toBe(true); | ||
}); | ||
|
||
it('MuteGroup', () => { | ||
const bus1 = conn.muteGroup(2); | ||
const bus2 = conn.muteGroup(2); | ||
expect(bus1 === bus2).toBe(true); | ||
}); | ||
|
||
it('HwChannel', () => { | ||
const ch1 = conn.hw(4); | ||
const ch2 = conn.hw(4); | ||
expect(ch1 === ch2).toBe(true); | ||
}); | ||
}); | ||
}); |
12 changes: 12 additions & 0 deletions
12
packages/mixer-connection/src/lib/state/channel-store.spec.ts
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,12 @@ | ||
import { ChannelStore } from './channel-store'; | ||
|
||
describe('Channel Store', () => { | ||
it('should store and retrieve an object', () => { | ||
const store = new ChannelStore(); | ||
const myObject = { foo: 'bar', bar: 5 }; | ||
|
||
store.set('myKey', myObject); | ||
|
||
expect(store.get('myKey')).toBe(myObject); | ||
}); | ||
}); |