Skip to content

Commit

Permalink
Merge pull request #15227 from brollin/improve-keyboard-move-testing
Browse files Browse the repository at this point in the history
Improve keyboard move testing
  • Loading branch information
ornicar authored May 6, 2024
2 parents d599a8a + e587a5d commit a28ab6b
Show file tree
Hide file tree
Showing 10 changed files with 834 additions and 1,097 deletions.
359 changes: 0 additions & 359 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

9 changes: 0 additions & 9 deletions ui/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,6 @@ cd ui/
pnpm test
```

### VSCode

The Jest extension is your friend. You will want to configure the following in your `settings.json`:

```
"jest.rootPath": "ui",
"jest.jestCommandLine": "node_modules/.bin/jest --config jest.config.js",
```

## CSS

The structure of a CSS module is as follows:
Expand Down
4 changes: 2 additions & 2 deletions ui/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/* eslint-env node */
module.exports = {
testMatch: ['**/dist/**/*.test.js'],
testEnvironment: 'jsdom',
testEnvironment: 'node',
transform: {},
globals: {
lichess: {},
site: {},
},
};
3 changes: 3 additions & 0 deletions ui/keyboardMove/src/ctrl.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as cg from 'chessground/types';
import { SanToUci } from 'chess';
import { h } from 'snabbdom';
import { onInsert } from 'common/snabbdom';
import { promote } from 'chess/promotion';
Expand All @@ -24,6 +25,7 @@ export interface KeyboardMove {
hasSelected(): cg.Key | undefined;
confirmMove(): void;
usedSan: boolean;
legalSans: SanToUci | null;
arrowNavigate(arrowKey: ArrowKey): void;
justSelected(): boolean;
draw(): void;
Expand Down Expand Up @@ -128,6 +130,7 @@ export function ctrl(root: KeyboardMoveRootCtrl): KeyboardMove {
hasSelected: () => cg.state.selected,
confirmMove: () => (root.submitMove ? root.submitMove(true) : null),
usedSan,
legalSans: null,
arrowNavigate(arrowKey: ArrowKey) {
if (root.handleArrowKey) {
root.handleArrowKey?.(arrowKey);
Expand Down
Loading

0 comments on commit a28ab6b

Please sign in to comment.