Skip to content

Commit

Permalink
Write assertions against real world scrambled puzzle
Browse files Browse the repository at this point in the history
  • Loading branch information
ajhyndman committed Sep 4, 2023
1 parent 41a42ae commit f54e0c3
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion test/index.test.ts
Original file line number Diff line number Diff line change
@@ -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 = [
Expand Down Expand Up @@ -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'));
});
});

0 comments on commit f54e0c3

Please sign in to comment.