-
-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: granular endpoints for rundown
- Loading branch information
Showing
8 changed files
with
145 additions
and
18 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
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
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
39 changes: 39 additions & 0 deletions
39
apps/server/src/services/rundown-service/__tests__/rundownUtils.test.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,39 @@ | ||
import { OntimeRundown } from 'ontime-types'; | ||
import { getPaginated } from '../rundownUtils.js'; | ||
|
||
describe('getPaginated', () => { | ||
// mock cache so we dont run data functions | ||
beforeAll(() => { | ||
vi.mock('../rundownCache.js', () => ({})); | ||
}); | ||
|
||
// @ts-expect-error -- we know this is not correct, but good enough for the test | ||
const getData = () => [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] as OntimeRundown; | ||
|
||
it('should return the correct paginated rundown', () => { | ||
const offset = 0; | ||
const limit = 1; | ||
const result = getPaginated(offset, limit, getData); | ||
|
||
expect(result.rundown).toHaveLength(1); | ||
expect(result.total).toBe(10); | ||
}); | ||
|
||
it('should handle overflows', () => { | ||
const offset = 0; | ||
const limit = 20; | ||
const result = getPaginated(offset, limit, getData); | ||
|
||
expect(result.rundown).toHaveLength(10); | ||
expect(result.total).toBe(10); | ||
}); | ||
|
||
it('should handle out of range', () => { | ||
const offset = 11; | ||
const limit = Infinity; | ||
const result = getPaginated(offset, limit, getData); | ||
|
||
expect(result.rundown).toHaveLength(0); | ||
expect(result.total).toBe(10); | ||
}); | ||
}); |
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
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
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
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