Skip to content

Commit c085d4b

Browse files
committed
Move tests from mocha to bun test
1 parent 878d4f9 commit c085d4b

7 files changed

Lines changed: 188 additions & 208 deletions

File tree

build/tests/input.test.ts

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import { expect, describe, test } from 'bun:test'
2+
import { InputLocations } from '../src/types'
3+
import { gitReadFunc } from '../src/git'
4+
5+
const inputLocationsPromise: Promise<InputLocations> = await gitReadFunc(
6+
process.env['BRANCH']!,
7+
'input-locations.json'
8+
).then(data => JSON.parse(data!))
9+
10+
describe('InputLocations', () => {
11+
test('json structure', async () => {
12+
const inputLocations = await inputLocationsPromise
13+
expect(typeof inputLocations === 'object', 'Json not valid: Not an array').toBe(true)
14+
expect(Array.isArray(inputLocations), 'Json not valid: Not an array').toBe(true)
15+
expect(inputLocations !== null, 'Json not valid: Not an array').toBe(true)
16+
})
17+
18+
describe('mods', async () => {
19+
const inputLocations = await inputLocationsPromise
20+
for (let i = 0; i < inputLocations.length; i++) {
21+
const loc = inputLocations[i]
22+
test(loc.url, async () => {
23+
expect(
24+
[undefined, 'zip'],
25+
'type (type: string) must be one of: [undefined, "zip"]'
26+
).toContain(loc.type)
27+
28+
switch (loc.type) {
29+
case undefined:
30+
case 'zip':
31+
expect(loc.url).toBeTypeOf('string')
32+
expect(
33+
loc.source === undefined || typeof loc.source === 'string'
34+
).toBeTrue()
35+
break
36+
}
37+
})
38+
}
39+
})
40+
})

build/tests/input.ts

Lines changed: 0 additions & 46 deletions
This file was deleted.

0 commit comments

Comments
 (0)