45 lines
1.1 KiB
TypeScript
45 lines
1.1 KiB
TypeScript
import fs from 'fs';
|
|
import { expect, test } from 'bun:test';
|
|
import path from 'path';
|
|
import { parseEventInfo, parseEventList, sneckGroup } from '../src/utils';
|
|
|
|
|
|
const matchId = '167684';
|
|
const item_id = '7098063';
|
|
test('event list not empty', () => {
|
|
const html = fs.readFileSync(path.resolve(__dirname, 'data', 'view-event.html')).toString();
|
|
const list = parseEventList(html);
|
|
expect(list.length).toBe(10);
|
|
console.log(list[0]?.matchId);
|
|
});
|
|
|
|
test('event content not empty', () => {
|
|
const html = fs.readFileSync(
|
|
path.resolve(__dirname, 'data', 'view-event-content.html')
|
|
).toString();
|
|
const { itemId, players } = parseEventInfo(html);
|
|
expect(itemId).toBe(item_id);
|
|
expect(players.length).toBeGreaterThan(0);
|
|
console.log(players);
|
|
expect(players[0]?.uid).not.toBe('');
|
|
});
|
|
|
|
test("group", () => {
|
|
const group = sneckGroup(48, 6);
|
|
/**
|
|
* A B
|
|
* [01] [07]
|
|
* [02] [08]
|
|
* [05] [09]
|
|
* [06] [10]
|
|
* A B
|
|
* [01] [08]
|
|
* [07] [02]
|
|
* [05] [10]
|
|
* [09] [06]
|
|
*/
|
|
expect(group?.[0]?.[0]).toBe(0);
|
|
expect(group?.[0]?.[1]).toBe(11);
|
|
expect(group?.[1]?.[0]).toBe(1);
|
|
expect(group?.[1]?.[1]).toBe(10);
|
|
}) |