/
fenwoody.test.ts
43 lines (39 loc) · 1.1 KB
/
fenwoody.test.ts
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
import { convertFenToSvg } from './src/convert-fen';
import { validateFen } from './src/fen';
import { FenWoodyOptions, initialFEN } from './src/types';
describe('Fenwoody', () => {
const options: FenWoodyOptions = {
inverted: false,
showCoordinates: true,
outputFormat: 'svg',
};
const svg = convertFenToSvg(initialFEN, options);
console.log(svg);
test('should return a string', () => {
expect(typeof svg).toBe('string');
});
test('should return a valid svg', () => {
// expect(svg).toMatch(/^<svg/);
expect(svg).toMatch(/<svg(.*)>[^]*<\/svg>/m);
});
});
const FenStrings = [
{
fen: 'rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1',
valid: true,
},
{
fen: 'rnbqkbnr/pp1ppppp/8/2p5/4P3/5N2/PPPP1PPP/RNBQKB1R b KQkq - 1 2',
valid: true,
},
{
fen: 'rnbqkbnr/pp1ppppp/81/2p5/4P3/5N2/PPPP1PPP/RNBQKB1R b KQkq - 1 2',
valid: false,
},
];
describe('Validate a fen string', () => {
test.each(FenStrings)('should return $valid for $fen', ({ fen, valid }) => {
expect(validateFen(fen)).toBe(valid);
});
});
// Path: fenwoody.test.ts