Skip to content

Commit

Permalink
Add and update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
vojtechpavlu committed Mar 17, 2024
1 parent 249a271 commit 9ab7167
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
32 changes: 32 additions & 0 deletions test/baseGenerators/numeric/ConstantNumberGenerator.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { ConstantNumberGenerator } from '../../../src';

describe('StringGenerator class', () => {
it('should return a specified string', () => {
const generator = new ConstantNumberGenerator({
num: 3
})

expect(generator.get()).toBe(3);
});

it('should raise an error on undefined value', () => {
const conf = { num: undefined }

//@ts-ignore
expect(() => new ConstantNumberGenerator(conf)).toThrow();
});

it('should raise an error on null value', () => {
const conf = { num: null }

//@ts-ignore
expect(() => new ConstantNumberGenerator(conf)).toThrow();
});

it('should raise an error on not-number value', () => {
const conf = { num: "string" }

//@ts-ignore
expect(() => new ConstantNumberGenerator(conf)).toThrow();
});
});
7 changes: 7 additions & 0 deletions test/baseGenerators/string/ConstantStringGenerator.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,11 @@ describe('StringGenerator class', () => {
//@ts-ignore
expect(() => new ConstantStringGenerator(conf)).toThrow();
});

it('should raise an error on non-string value', () => {
const conf = { text: 1 }

//@ts-ignore
expect(() => new ConstantStringGenerator(conf)).toThrow();
});
});

0 comments on commit 9ab7167

Please sign in to comment.