cm-chessboard 8.7.1 → 8.7.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/test/TestChessboard.js +21 -2
- package/test/TestPosition.js +19 -1
- package/test/index.html +0 -1
- package/test/TestBoard.js +0 -32
package/package.json
CHANGED
package/test/TestChessboard.js
CHANGED
|
@@ -10,12 +10,31 @@ import {FEN} from "../src/model/Position.js"
|
|
|
10
10
|
|
|
11
11
|
describe("TestChessboard", () => {
|
|
12
12
|
|
|
13
|
+
// https://github.com/shaack/cm-chessboard/issues/47
|
|
14
|
+
it("should create and immediately destroy a board without failure", () => {
|
|
15
|
+
const chessboard = new Chessboard(document.getElementById("TestBoard"), {
|
|
16
|
+
assetsUrl: "../assets/",
|
|
17
|
+
position: FEN.start
|
|
18
|
+
})
|
|
19
|
+
chessboard.destroy()
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
it("should create and destroy a board", () => {
|
|
23
|
+
const chessboard = new Chessboard(document.getElementById("TestBoard"), {
|
|
24
|
+
assetsUrl: "../assets/",
|
|
25
|
+
position: FEN.start
|
|
26
|
+
})
|
|
27
|
+
assert.equal(chessboard.view.container.childNodes.length, 1)
|
|
28
|
+
chessboard.destroy()
|
|
29
|
+
assert.equal(chessboard.state, undefined)
|
|
30
|
+
})
|
|
31
|
+
|
|
13
32
|
it("should create and destroy a chessboard", () => {
|
|
14
33
|
const chessboard = new Chessboard(document.getElementById("TestPosition"), {
|
|
15
34
|
assetsUrl: "../assets/",
|
|
16
35
|
position: FEN.start
|
|
17
36
|
})
|
|
18
|
-
assert.equal(chessboard.getPosition(), "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR")
|
|
37
|
+
assert.equal("" + chessboard.getPosition(), "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR")
|
|
19
38
|
chessboard.destroy()
|
|
20
39
|
})
|
|
21
40
|
|
|
@@ -23,7 +42,7 @@ describe("TestChessboard", () => {
|
|
|
23
42
|
const chessboard = new Chessboard(document.getElementById("TestPosition"),
|
|
24
43
|
{assetsUrl: "../assets/"})
|
|
25
44
|
chessboard.setPosition("rn2k1r1/ppp1pp1p/3p2p1/5bn1/P7/2N2B2/1PPPPP2/2BNK1RR w Gkq - 4 11", false).then(() => {
|
|
26
|
-
assert.equal(chessboard.getPosition(), "rn2k1r1/ppp1pp1p/3p2p1/5bn1/P7/2N2B2/1PPPPP2/2BNK1RR")
|
|
45
|
+
assert.equal("" + chessboard.getPosition(), "rn2k1r1/ppp1pp1p/3p2p1/5bn1/P7/2N2B2/1PPPPP2/2BNK1RR")
|
|
27
46
|
chessboard.destroy()
|
|
28
47
|
})
|
|
29
48
|
})
|
package/test/TestPosition.js
CHANGED
|
@@ -5,7 +5,8 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import {describe, it, assert} from "../node_modules/teevi/src/teevi.js"
|
|
8
|
-
import {Position} from "../src/model/Position.js"
|
|
8
|
+
import {FEN, Position} from "../src/model/Position.js"
|
|
9
|
+
import {COLOR, PIECE_TYPE} from "../src/Chessboard.js"
|
|
9
10
|
|
|
10
11
|
describe("TestPosition", () => {
|
|
11
12
|
it("should convert square to index", () => {
|
|
@@ -22,4 +23,21 @@ describe("TestPosition", () => {
|
|
|
22
23
|
assert.equal(Position.indexToSquare(38), "g5")
|
|
23
24
|
assert.equal(Position.indexToSquare(63), "h8")
|
|
24
25
|
})
|
|
26
|
+
it("should return the correct FEN string", () => {
|
|
27
|
+
const position = new Position(FEN.start)
|
|
28
|
+
assert.equal(position.getFen(), "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR")
|
|
29
|
+
})
|
|
30
|
+
it("should find the correct pieces", () => {
|
|
31
|
+
const position = new Position("8/5P2/8/1P3r2/8/8/1P3P1P/8")
|
|
32
|
+
const blackPiece = position.getPieces(undefined, COLOR.black)
|
|
33
|
+
assert.equal(blackPiece.length, 1)
|
|
34
|
+
assert.equal(blackPiece[0].type, PIECE_TYPE.rook)
|
|
35
|
+
assert.equal(blackPiece[0].square, "f5")
|
|
36
|
+
const whitePieces = position.getPieces(undefined, COLOR.white)
|
|
37
|
+
assert.equal(whitePieces.length, 5)
|
|
38
|
+
const rooks = position.getPieces(PIECE_TYPE.rook)
|
|
39
|
+
assert.equal(rooks.length, 1)
|
|
40
|
+
assert.equal(rooks[0].square, "f5")
|
|
41
|
+
})
|
|
25
42
|
})
|
|
43
|
+
|
package/test/index.html
CHANGED
package/test/TestBoard.js
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Author and copyright: Stefan Haack (https://shaack.com)
|
|
3
|
-
* Repository: https://github.com/shaack/cm-chessboard
|
|
4
|
-
* License: MIT, see file 'LICENSE'
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import {describe, it, assert} from "../node_modules/teevi/src/teevi.js"
|
|
8
|
-
import {Chessboard} from "../src/Chessboard.js"
|
|
9
|
-
import {FEN} from "../src/model/Position.js"
|
|
10
|
-
|
|
11
|
-
describe("TestBoard", () => {
|
|
12
|
-
|
|
13
|
-
// https://github.com/shaack/cm-chessboard/issues/47
|
|
14
|
-
it("should create and immediately destroy a board without failure", () => {
|
|
15
|
-
const chessboard = new Chessboard(document.getElementById("TestBoard"), {
|
|
16
|
-
assetsUrl: "../assets/",
|
|
17
|
-
position: FEN.start
|
|
18
|
-
})
|
|
19
|
-
chessboard.destroy()
|
|
20
|
-
})
|
|
21
|
-
|
|
22
|
-
it("should create and destroy a board", () => {
|
|
23
|
-
const chessboard = new Chessboard(document.getElementById("TestBoard"), {
|
|
24
|
-
assetsUrl: "../assets/",
|
|
25
|
-
position: FEN.start
|
|
26
|
-
})
|
|
27
|
-
assert.equal(chessboard.view.container.childNodes.length, 1)
|
|
28
|
-
chessboard.destroy()
|
|
29
|
-
assert.equal(chessboard.state, undefined)
|
|
30
|
-
})
|
|
31
|
-
|
|
32
|
-
})
|