Skip to content

Commit

Permalink
add test for parser
Browse files Browse the repository at this point in the history
  • Loading branch information
Niklas Lennerdahl committed Nov 1, 2023
1 parent 4952afe commit de6047f
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions tests/parser.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { expect } from "chai";
import {parseToNumberOrUndefined} from '../src/lib/parser';

describe('Parser Test', () => {
it('Shoould return number', () => {
const result: number | undefined = parseToNumberOrUndefined('1');
expect(result).to.be.equals(1)
})

const values: string[] = [' ', 'hej', null, undefined]
values.forEach((value: string) => {
it('Shoould return undefined', () => {
const result: number | undefined = parseToNumberOrUndefined(value);
expect(result).to.be.undefined;
})
})
})

0 comments on commit de6047f

Please sign in to comment.