1
0
Fork 0
mirror of https://github.com/demostf/demo.js synced 2026-06-04 00:54:14 +02:00

add basic snapshot test

This commit is contained in:
Robin Appelman 2017-02-12 16:33:30 +01:00
commit 641f5419df
11 changed files with 2004 additions and 0 deletions

1
src/tests/data/.gitignore vendored Normal file
View file

@ -0,0 +1 @@
!*.dem

Binary file not shown.

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,20 @@
import {readFileSync} from 'fs';
import {Demo} from "../../Demo";
import * as assert from 'assert';
function testDemo(name: string) {
const target = JSON.parse(readFileSync(`${__dirname}/../data/${name}.json`, 'utf8'));
const source = readFileSync(`${__dirname}/../data/${name}.dem`);
const demo = Demo.fromNodeBuffer(source);
const parser = demo.getParser();
parser.readHeader();
parser.parseBody();
const parsed = parser.match.getState();
assert.deepEqual(parsed, target);
}
suite('Parse basic demo info', () => {
test('Parse snakewater.dem', () => {
testDemo('snakewater');
});
});