From f54e0c3a64755ee121fc13d244cea9b88c351c9c Mon Sep 17 00:00:00 2001 From: Andrew Hyndman Date: Mon, 4 Sep 2023 18:22:39 -0400 Subject: [PATCH] Write assertions against real world scrambled puzzle --- test/index.test.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/test/index.test.ts b/test/index.test.ts index 89ca4ff..51a837c 100644 --- a/test/index.test.ts +++ b/test/index.test.ts @@ -1,7 +1,7 @@ import { readFileSync } from 'fs'; import { join } from 'path'; -import { parseBinaryFile, printBinaryFile, printTextFile } from '../src/index'; +import { parseBinaryFile, printBinaryFile, printTextFile, unscramble } from '../src/index'; describe('puz', () => { const puzzleFiles = [ @@ -45,4 +45,12 @@ describe('puz', () => { expect(printTextFile(puzzle)).toMatchSnapshot(); }); }); + + describe('unscramble unlocks puzzle', () => { + const buffer = readFileSync(join(__dirname, 'puzzles', 'nyt_locked.puz')); + const puzzle = parseBinaryFile(buffer); + const unscrambledPuzzle = unscramble(puzzle, '7844'); + expect(unscrambledPuzzle.isScrambled).toBe(false); + expect(unscrambledPuzzle.solution.startsWith('PANDORASBOX')); + }); });