Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
juusaw committed Feb 15, 2019
1 parent e24c418 commit a55ea8a
Show file tree
Hide file tree
Showing 4 changed files with 3,284 additions and 21 deletions.
4 changes: 4 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
};
10 changes: 8 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,19 @@
"author": "juusaw",
"license": "MIT",
"dependencies": {
"@types/graphql": "^14.0.7",
"apollo-server": "^2.4.0",
"graphql": "^14.1.1",
"ts-node": "^8.0.2",
"typescript": "^3.3.3"
},
"scripts": {
"start": "ts-node src/index.ts"
"start": "ts-node src/index.ts",
"test": "jest"
},
"devDependencies": {
"@types/graphql": "^14.0.7",
"@types/jest": "^24.0.5",
"jest": "^24.1.0",
"ts-jest": "^23.10.5"
}
}
13 changes: 13 additions & 0 deletions test/dice.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import * as dice from '../src/dice'

test('Parser', () => {
const cases = [
{ string: '2d6', result: [[2, 6]] },
{ string: '1d6+1', result: [[1, 6], [1, 1]] },
{ string: '0d6+1', result: [[0, 6], [1, 1]] },
{ string: '-2d20+5', result: [[-2, 20], [5, 1]] },
{ string: '3d8-10', result: [[3, 8], [-10, 1]] },
]
cases.forEach(({ string, result }) =>
expect(dice.parseDice(string)).toEqual(result))
})
Loading

0 comments on commit a55ea8a

Please sign in to comment.