Skip to content

Commit

Permalink
fix: msElapsed is now reset to 0 between multiple parses (#21)
Browse files Browse the repository at this point in the history
  • Loading branch information
PBug90 authored Apr 26, 2019
1 parent 1c88c74 commit 6a6b4c7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/ReplayParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class ReplayParser extends EventEmitter{

parse($buffer: string) {
console.time('parse')
this.msElapsed = 0
this.buffer = readFileSync($buffer)
this.buffer = this.buffer.slice(this.buffer.indexOf('Warcraft III recorded game'))
this.filename = $buffer
Expand Down
8 changes: 8 additions & 0 deletions test/replays.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,14 @@ describe('Replay parsing tests', () => {
validatorInstance.validate(test, schema, {throwError: true})
})

it('resets elapsedMS instance property to 0 before parsing another replay', () => {
Parser.parse(`./replays/standard_130.w3g`)
const msElapsed = Parser.msElapsed
Parser.parse(`./replays/standard_130.w3g`)
const msElapsedTwo = Parser.msElapsed
expect(msElapsed).toEqual(msElapsedTwo)
})

it('parses a standard 1.30.2 replay properly', () => {
const test = Parser.parse(`./replays/standard_1302.w3g`)
expect(test.version).toBe('1.30.2+')
Expand Down

0 comments on commit 6a6b4c7

Please sign in to comment.