Created
April 25, 2019 07:15
-
-
Save krukru/0ac16e15cd793334051a96bd2da6d22f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// services/validators/ExampleValidator.js | |
export class ExampleValidator { | |
validateFoo(input) { | |
return input.length === 5; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//test/services/validators/ExampleValidator.test.js | |
import {ExampleValidator} from '@/services/validators/ExampleValidator'; | |
describe('ExampleValidator', function () { | |
let validator; | |
beforeEach(function () { | |
validator = new ExampleValidator(); | |
}); | |
const testCases = [ | |
[5, false], | |
[undefined, false], | |
[null, false], | |
['', false], | |
['5', false], | |
[12345, false], | |
['12345', true], | |
]; | |
testCases.forEach((testCase) => { | |
const [input, expected] = testCase; | |
test('validateFoo', () => { | |
const result = validator.validateFoo(input); | |
expect(result).toBe(expected); | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment