|
| 1 | +import { anagrams, easyAnagram } from '../anagrams'; |
| 2 | +import { describe, test } from 'vitest'; |
| 3 | + |
| 4 | +describe('Anagrams Algorithm', () => { |
| 5 | + test('anagrams function exists', () => { |
| 6 | + expect(typeof anagrams).toEqual('function'); |
| 7 | + expect(typeof easyAnagram).toEqual('function'); |
| 8 | + }); |
| 9 | + |
| 10 | + test('"hello" is an anagram of "llohe"', () => { |
| 11 | + expect(anagrams('hello', 'llohe')).toBeTruthy(); |
| 12 | + expect(easyAnagram('hello', 'llohe')).toBeTruthy(); |
| 13 | + }); |
| 14 | + |
| 15 | + test('"Whoa! Hi!" is an anagram of "Hi! Whoa!"', () => { |
| 16 | + expect(anagrams('Whoa! Hi!', 'Hi! Whoa!')).toBeTruthy(); |
| 17 | + expect(easyAnagram('Whoa! Hi!', 'Hi! Whoa!')).toBeTruthy(); |
| 18 | + }); |
| 19 | + |
| 20 | + test('"One One" is not an anagram of "Two two two"', () => { |
| 21 | + expect(anagrams('One One', 'Two two two')).toBeFalsy(); |
| 22 | + expect(easyAnagram('One One', 'Two two two')).toBeFalsy(); |
| 23 | + }); |
| 24 | + |
| 25 | + test('"One one" is not an anagram of "One one c"', () => { |
| 26 | + expect(anagrams('One one', 'One one c')).toBeFalsy(); |
| 27 | + expect(easyAnagram('One one', 'One one c')).toBeFalsy(); |
| 28 | + }); |
| 29 | + |
| 30 | + test('"A tree, a life, a bench" is not an anagram of "A tree, a fence, a yard"', () => { |
| 31 | + expect( |
| 32 | + anagrams('A tree, a life, a bench', 'A tree, a fence, a yard'), |
| 33 | + ).toBeFalsy(); |
| 34 | + expect( |
| 35 | + easyAnagram('A tree, a life, a bench', 'A tree, a fence, a yard'), |
| 36 | + ).toBeFalsy(); |
| 37 | + }); |
| 38 | +}); |
0 commit comments