odin-default-js-exercises/archive/archived_snakeCase/solution/snakeCase-solution.spec.js

27 lines
847 B
JavaScript
Raw Normal View History

2023-02-01 23:53:54 +00:00
const snakeCase = require('./snakeCase-solution');
2017-08-25 19:16:42 +00:00
describe('snakeCase', () => {
test('works with simple lowercased phrases', () => {
2017-08-25 19:16:42 +00:00
expect(snakeCase('hello world')).toEqual('hello_world');
});
2023-02-01 23:58:58 +00:00
test('works with Caps and punctuation', () => {
2017-08-25 19:16:42 +00:00
expect(snakeCase('Hello, World???')).toEqual('hello_world');
});
2023-02-01 23:58:58 +00:00
test('works with longer phrases', () => {
2023-02-01 23:53:54 +00:00
expect(snakeCase('This is the song that never ends....')).toEqual(
'this_is_the_song_that_never_ends'
);
2017-08-25 19:16:42 +00:00
});
2023-02-01 23:58:58 +00:00
test('works with camel case', () => {
2017-08-25 19:16:42 +00:00
expect(snakeCase('snakeCase')).toEqual('snake_case');
});
2023-02-01 23:58:58 +00:00
test('works with kebab case', () => {
2017-08-25 19:16:42 +00:00
expect(snakeCase('snake-case')).toEqual('snake_case');
});
2023-02-01 23:58:58 +00:00
test('works with WTF case', () => {
2023-02-01 23:53:54 +00:00
expect(snakeCase('SnAkE..CaSe..Is..AwEsOmE')).toEqual(
'snake_case_is_awesome'
);
2017-08-25 19:16:42 +00:00
});
});