odin-default-js-exercises/03_reverseString/solution/reverseString-solution.spec.js

19 lines
523 B
JavaScript
Raw Permalink Normal View History

2023-02-01 23:53:54 +00:00
const reverseString = require('./reverseString-solution');
2022-02-20 19:07:44 +00:00
2023-02-01 23:53:54 +00:00
describe('reverseString', () => {
test('reverses single word', () => {
expect(reverseString('hello')).toEqual('olleh');
2023-01-21 17:53:41 +00:00
});
2022-02-20 19:07:44 +00:00
2023-02-01 23:58:58 +00:00
test('reverses multiple words', () => {
2023-02-01 23:53:54 +00:00
expect(reverseString('hello there')).toEqual('ereht olleh');
2023-01-21 17:53:41 +00:00
});
2022-02-20 19:07:44 +00:00
2023-02-01 23:58:58 +00:00
test('works with numbers and punctuation', () => {
2023-02-01 23:53:54 +00:00
expect(reverseString('123! abc!')).toEqual('!cba !321');
2023-01-21 17:53:41 +00:00
});
2023-02-01 23:58:58 +00:00
test('works with blank strings', () => {
2023-02-01 23:53:54 +00:00
expect(reverseString('')).toEqual('');
2023-01-21 17:53:41 +00:00
});
2022-02-20 19:07:44 +00:00
});