-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: refactor chef device SOFIE-2494
- Loading branch information
Showing
7 changed files
with
278 additions
and
437 deletions.
There are no files selected for viewing
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
99 changes: 99 additions & 0 deletions
99
packages/timeline-state-resolver/src/integrations/sofieChef/__tests__/diffStates.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,99 @@ | ||
import { diffStates } from '../diffStates' | ||
import { SofieChefCommandWithContext, SofieChefState } from '..' | ||
import { ReceiveWSMessageType } from '../api' | ||
|
||
describe('Diff States', () => { | ||
test('Simple diff against undefined state', async () => { | ||
const state1: SofieChefState = { | ||
windows: { | ||
test: { | ||
url: 'http://test.com', | ||
urlTimelineObjId: 'abc', | ||
}, | ||
}, | ||
} | ||
|
||
const commands = diffStates(undefined, state1, {}) | ||
|
||
expect(commands).toHaveLength(1) | ||
expect(commands[0]).toEqual({ | ||
command: { | ||
msgId: 0, | ||
type: ReceiveWSMessageType.PLAYURL, | ||
url: 'http://test.com', | ||
windowId: 'test', | ||
}, | ||
context: 'added', | ||
timelineObjId: 'abc', | ||
} satisfies SofieChefCommandWithContext) | ||
}) | ||
|
||
test('Simple diff against another state', async () => { | ||
const state1: SofieChefState = { | ||
windows: { | ||
test: { | ||
url: 'http://test.com', | ||
urlTimelineObjId: 'abc', | ||
}, | ||
two: { | ||
url: 'http://two.com', | ||
urlTimelineObjId: 'def', | ||
}, | ||
three: { | ||
url: 'http://three.com', | ||
urlTimelineObjId: 'ghi', | ||
}, | ||
}, | ||
} | ||
|
||
const state2: SofieChefState = { | ||
windows: { | ||
two: { | ||
url: 'http://two.com/2', | ||
urlTimelineObjId: '012', | ||
}, | ||
another: { | ||
url: 'http://another.com', | ||
urlTimelineObjId: '345', | ||
}, | ||
three: { | ||
url: 'http://three.com', | ||
urlTimelineObjId: 'ghi', | ||
}, | ||
}, | ||
} | ||
|
||
const commands = diffStates(state1, state2, {}) | ||
|
||
expect(commands).toHaveLength(3) | ||
expect(commands[0]).toEqual({ | ||
command: { | ||
msgId: 0, | ||
type: ReceiveWSMessageType.PLAYURL, | ||
url: 'http://two.com/2', | ||
windowId: 'two', | ||
}, | ||
context: 'changed', | ||
timelineObjId: '012', | ||
} satisfies SofieChefCommandWithContext) | ||
expect(commands[1]).toEqual({ | ||
command: { | ||
msgId: 0, | ||
type: ReceiveWSMessageType.PLAYURL, | ||
url: 'http://another.com', | ||
windowId: 'another', | ||
}, | ||
context: 'added', | ||
timelineObjId: '345', | ||
} satisfies SofieChefCommandWithContext) | ||
expect(commands[2]).toEqual({ | ||
command: { | ||
msgId: 0, | ||
type: ReceiveWSMessageType.STOP, | ||
windowId: 'test', | ||
}, | ||
context: 'removed', | ||
timelineObjId: 'abc', | ||
} satisfies SofieChefCommandWithContext) | ||
}) | ||
}) |
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
Oops, something went wrong.