Created
October 21, 2021 17:05
-
-
Save phatnguyenuit/b5eecb0e1d0dff158600134d29aa3ab8 to your computer and use it in GitHub Desktop.
Prevent code duplication when writing unit tests with Jest .each - duplication test cases
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
import { toKebabCase } from './utils'; | |
describe('toKebabCase', () => { | |
it('should work from empty string', () => { | |
expect(toKebabCase('')).toEqual(''); | |
}); | |
it('should return "my-example" when given "my_example"', () => { | |
expect(toKebabCase('my_example')).toEqual('my-example'); | |
}); | |
it('should return "another-example" when given "Another-Example"', () => { | |
expect(toKebabCase('Another-Example')).toEqual('another-example'); | |
}); | |
it('should return "another-example" when given "anotherExample"', () => { | |
expect(toKebabCase('anotherExample')).toEqual('another-example'); | |
}); | |
it('should return "another-example-1-2-3" when given "anotherExample123"', () => { | |
expect(toKebabCase('anotherExample123')).toEqual('another-example-1-2-3'); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment