|
1 |
| -import { |
2 |
| - ReverseStringIterative, |
3 |
| - ReverseStringIterativeInplace |
4 |
| -} from '../ReverseString' |
| 1 | +import { ReverseStringIterative, ReverseStringIterativeInplace } from '../ReverseString' |
5 | 2 |
|
6 | 3 | describe('ReverseStringIterative', () => {
|
7 | 4 | it('expects to reverse a simple string', () => {
|
8 |
| - const SUT = ReverseStringIterative('reverse') |
9 |
| - expect(SUT).toEqual('esrever') |
| 5 | + expect(ReverseStringIterative('reverse')).toEqual('esrever') |
| 6 | + expect(ReverseStringIterative('some')).toEqual('emos') |
| 7 | + expect(ReverseStringIterative('string')).toEqual('gnirts') |
| 8 | + expect(ReverseStringIterative('The Algorithms Javascript')).toEqual('tpircsavaJ smhtiroglA ehT') |
10 | 9 | })
|
| 10 | + |
11 | 11 | it('expects to reverse a string with spaces in between', () => {
|
12 |
| - const SUT = ReverseStringIterative('reverse me') |
13 |
| - expect(SUT).toEqual('em esrever') |
| 12 | + expect(ReverseStringIterative('reverse me')).toEqual('em esrever') |
14 | 13 | })
|
| 14 | + |
15 | 15 | it('expects to reverse a simple string without capitalizing the first letter', () => {
|
16 |
| - const SUT = ReverseStringIterative('Javascript') |
17 |
| - expect(SUT).toEqual('tpircsavaJ') |
| 16 | + expect(ReverseStringIterative('Javascript')).toEqual('tpircsavaJ') |
18 | 17 | })
|
| 18 | + |
19 | 19 | it.each`
|
20 | 20 | input
|
21 | 21 | ${123456}
|
22 | 22 | ${[1, 2, 3, 4, 5, 6]}
|
23 | 23 | ${{ test: 'test' }}
|
| 24 | + ${null} |
24 | 25 | `(
|
25 | 26 | 'expects to throw a type error given a value that is $input',
|
26 | 27 | ({ input }) => {
|
27 |
| - expect(() => { |
28 |
| - ReverseStringIterative(input) |
29 |
| - }).toThrow('The given value is not a string') |
| 28 | + expect(() => ReverseStringIterative(input)).toThrow('The given value is not a string') |
30 | 29 | }
|
31 | 30 | )
|
| 31 | + |
32 | 32 | it('expects to return a empty string with an empty string is given', () => {
|
33 |
| - const SUT = ReverseStringIterative('') |
34 |
| - expect(SUT).toEqual('') |
| 33 | + expect(ReverseStringIterative('')).toEqual('') |
35 | 34 | })
|
36 | 35 | })
|
| 36 | + |
37 | 37 | describe('ReverseStringIterativeInplace', () => {
|
38 | 38 | it('expects to reverse a simple string', () => {
|
39 |
| - const SUT = ReverseStringIterativeInplace('reverse') |
40 |
| - expect(SUT).toEqual('esrever') |
| 39 | + expect(ReverseStringIterativeInplace('reverse')).toEqual('esrever') |
| 40 | + expect(ReverseStringIterativeInplace('some')).toEqual('emos') |
| 41 | + expect(ReverseStringIterativeInplace('string')).toEqual('gnirts') |
| 42 | + expect(ReverseStringIterativeInplace('The Algorithms Javascript')).toEqual('tpircsavaJ smhtiroglA ehT') |
41 | 43 | })
|
| 44 | + |
42 | 45 | it('expects to reverse a simple string without capitalizing the first letter', () => {
|
43 |
| - const SUT = ReverseStringIterativeInplace('Javascript') |
44 |
| - expect(SUT).toEqual('tpircsavaJ') |
| 46 | + expect(ReverseStringIterativeInplace('Javascript')).toEqual('tpircsavaJ') |
45 | 47 | })
|
| 48 | + |
46 | 49 | it('expects to return an empty string given an empty string', () => {
|
47 |
| - const SUT = ReverseStringIterativeInplace('Javascript') |
48 |
| - expect(SUT).toEqual('tpircsavaJ') |
| 50 | + expect(ReverseStringIterativeInplace('Javascript')).toEqual('tpircsavaJ') |
49 | 51 | })
|
| 52 | + |
50 | 53 | it.each`
|
51 | 54 | input
|
52 | 55 | ${123456}
|
53 | 56 | ${[1, 2, 3, 4, 5, 6]}
|
54 | 57 | ${{ test: 'test' }}
|
| 58 | + ${null} |
55 | 59 | `(
|
56 | 60 | 'expects to throw a type error given a value that is $input',
|
57 | 61 | ({ input }) => {
|
58 |
| - expect(() => { |
59 |
| - ReverseStringIterativeInplace(input) |
60 |
| - }).toThrow('The given value is not a string') |
| 62 | + expect(() => ReverseStringIterativeInplace(input)).toThrow('The given value is not a string') |
61 | 63 | }
|
62 | 64 | )
|
63 | 65 | })
|
0 commit comments