Skip to content

Commit

Permalink
#436 Some test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
mliebelt committed Apr 24, 2023
1 parent 38b3a0c commit 8306431
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions modules/pgn-reader/test/reader.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import {PgnReaderMove} from "@mliebelt/pgn-types";

const should = require('chai').should()
import { expect } from 'chai'
import {PgnReader, Shape} from "../src"
Expand Down Expand Up @@ -780,6 +782,25 @@ describe("When using san and sanWithNags", function () {
should.equal(reader.sanWithNags(reader.getMove(0)),'e4⁉∞○')
should.equal(reader.writePgn(),'1. e4$5$13$27')
})
it ("should emmit correct discriminator", function () {
reader = new PgnReader({position: 'rnbqkbnr/p1p2p2/3p2p1/R3p2p/7P/8/1PPPPPP1/RNBQKBN1 w kq - 0 8'})
let san:string = reader.san(<PgnReaderMove>{nag: [], variations: [], from: 'a5', to: 'a3', notation: {}})
should.equal(san, "R5a3")
reader = new PgnReader({position: 'rnbqkbnr/p1p2p2/3p2p1/R3p2p/7P/8/1PPPPPP1/RNBQKBN1 w kq - 0 8'})
san = reader.san(<PgnReaderMove>{nag: [], variations: [], from: 'a1', to: 'a3', notation: {}})
should.equal(san, "R1a3")
reader = new PgnReader({position: 'r1b1kbnr/p2q1p2/2n1p2p/R1pp2p1/1PPP3P/5N2/4PPP1/RNBQKB2 w kq - 4 12'})
san = reader.san(<PgnReaderMove>{nag: [], variations: [], from: 'b1', to: 'd2', notation: {}})
should.equal(san, "Nbd2")
reader = new PgnReader({position: 'r1b1kbnr/p2q1p2/2n1p2p/R1pp2p1/1PPP3P/5N2/4PPP1/RNBQKB2 w kq - 4 12'})
san = reader.san(<PgnReaderMove>{nag: [], variations: [], from: 'f3', to: 'd2', notation: {}})
should.equal(san, "Nfd2")
})
it("should know pinned pieces when no discriminator is needed", function () {
reader = new PgnReader({ position: 'rnbqk1nr/pppp2pp/4p3/8/1b1Pp3/2N3N1/PPP2PPP/R1BQKB1R w KQkq - 0 1'})
let san:string = reader.san(<PgnReaderMove>{nag: [], variations: [], from: 'g3', to: 'e4', notation: {}})
should.equal(san, "Nxe4")
})
})

describe("When reading many games", function () {
Expand Down

0 comments on commit 8306431

Please sign in to comment.