Skip to content

Commit

Permalink
Add additional test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
adbutterfield committed Apr 15, 2020
1 parent fb88962 commit abe2201
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/validatiors.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,19 @@ describe('validators', () => {
});
});

it('returns false if the value passed is not a string', () => {
const minLength = 10;
const testString = 0;

const validatorFn = validateLengthIsGreaterThanOrEqualToMin(minLength);
const result = validatorFn<TestValues>(testString);

expect(result).toEqual({
type: 'minLength',
isValid: false,
});
});

it('returns true if the length of the value passed is greater than the min length', () => {
const minLength = 10;
const testString = 'long enough';
Expand Down Expand Up @@ -83,6 +96,19 @@ describe('validators', () => {
});
});

it('returns false if the value passed is not a string', () => {
const maxLength = 7;
const testString = 0;

const validatorFn = validateLengthIsLessThanOrEqualToMax(maxLength);
const result = validatorFn<TestValues>(testString);

expect(result).toEqual({
type: 'maxLength',
isValid: false,
});
});

it('returns true if the length of the value passed is less than the max length', () => {
const maxLength = 3;
const testString = 'ok';
Expand Down

0 comments on commit abe2201

Please sign in to comment.