100 lines
1.5 KiB
TypeScript
100 lines
1.5 KiB
TypeScript
import { validateBoardState } from './validate';
|
|
|
|
test('validates valid states', () => {
|
|
const inputs = [
|
|
{
|
|
"a": {
|
|
3: {
|
|
kind: "king",
|
|
color: "black",
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"b": {
|
|
5: {
|
|
kind: "rook",
|
|
color: "white",
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"c": {
|
|
8: {
|
|
kind: "bishop",
|
|
color: "black",
|
|
}
|
|
},
|
|
"e": {
|
|
4: {
|
|
kind: "pawn",
|
|
color: "white",
|
|
},
|
|
5: {
|
|
kind: "knight",
|
|
color: "white",
|
|
},
|
|
7: {
|
|
kind: "queen",
|
|
color: "black",
|
|
}
|
|
}
|
|
}
|
|
];
|
|
|
|
inputs.map((input) => {
|
|
const result = validateBoardState(input);
|
|
|
|
expect(result).not.toBeNull();
|
|
});
|
|
});
|
|
|
|
test('does not validate invalid states', () => {
|
|
const inputs = [
|
|
{
|
|
"j": {
|
|
3: {
|
|
kind: "king",
|
|
color: "black",
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"b": {
|
|
9: {
|
|
kind: "rook",
|
|
color: "white",
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"c": {
|
|
8: {
|
|
kind: "bishop",
|
|
color: "black",
|
|
}
|
|
},
|
|
"e": {
|
|
4: {
|
|
kind: "pawn",
|
|
color: "white",
|
|
},
|
|
5: {
|
|
type: "knight",
|
|
color: "white",
|
|
},
|
|
7: {
|
|
kind: "queen",
|
|
color: "black",
|
|
}
|
|
}
|
|
}
|
|
];
|
|
|
|
inputs.map((input) => {
|
|
const result = validateBoardState(input);
|
|
|
|
expect(result).toBeNull();
|
|
});
|
|
});
|