This repository was archived by the owner on Jul 1, 2026. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathcardSheetLayout.test.ts
More file actions
48 lines (45 loc) · 1.7 KB
/
Copy pathcardSheetLayout.test.ts
File metadata and controls
48 lines (45 loc) · 1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import { describe, expect, it } from 'vitest'
import {
buildCardSheetGridFromColumnRanges,
detectCardSheetLayout,
parseCardSheetRowsWithLayout,
} from './cardSheetLayout'
function buildV304CardRows(): string[][] {
const rows = Array.from({ length: 40 }, () => Array<string>(8).fill(''))
rows[4]![1] = 'Card Slot (Gems)'
rows[4]![2] = '18'
rows[5]![1] = 'Damage'
rows[5]![2] = '7'
rows[6]![1] = 'Attack Speed'
rows[6]![2] = '5'
rows[35]![1] = 'Area of Effect'
rows[35]![2] = 'Locked'
return rows
}
describe('cardSheetLayout', () => {
it('merges single-column B/C/D ranges', () => {
const grid = buildCardSheetGridFromColumnRanges([
{ range: "'Master Sheet'!B1:B60", values: [[], ['Damage'], ['Attack Speed']] },
{ range: "'Master Sheet'!C1:C60", values: [[], ['7'], ['5']] },
{ range: "'Master Sheet'!D1:D60", values: [[], ['TRUE'], ['FALSE']] },
])
expect(grid[1]![1]).toBe('Damage')
expect(grid[1]![2]).toBe('7')
expect(grid[1]![3]).toBe('TRUE')
expect(grid[2]![1]).toBe('Attack Speed')
})
it('detects Cards v3.x Master Sheet card block', () => {
const rows = buildV304CardRows()
const layout = detectCardSheetLayout(rows)
expect(layout).not.toBeNull()
const parsed = parseCardSheetRowsWithLayout(rows, layout!)
expect(parsed).toEqual(
expect.arrayContaining([
expect.objectContaining({ name: 'Card Slot (Gems)', kind: 'equip_slots', rowIndex: 5 }),
expect.objectContaining({ name: 'Damage', kind: 'card', rowIndex: 6 }),
expect.objectContaining({ name: 'Attack Speed', kind: 'card', rowIndex: 7 }),
expect.objectContaining({ name: 'Area of Effect', kind: 'card', rowIndex: 36 }),
]),
)
})
})