Test migration to jest by hand

Apparently using regular expressions is way easier.
This commit is contained in:
Angelos Chalaris
2018-06-18 15:15:56 +03:00
parent 5df7098fac
commit a78f5db260
894 changed files with 5917 additions and 3607 deletions

View File

@ -0,0 +1,11 @@
const isAnagram = (str1, str2) => {
const normalize = str =>
str
.toLowerCase()
.replace(/[^a-z0-9]/gi, '')
.split('')
.sort()
.join('');
return normalize(str1) === normalize(str2);
};
module.exports = isAnagram;

View File

@ -0,0 +1,21 @@
const expect = require('expect');
const isAnagram = require('./isAnagram.js');
test('isAnagram is a Function', () => {
expect(isAnagram).toBeInstanceOf(Function);
});
test('Checks valid anagram', () => {
expect(isAnagram('iceman', 'cinema')).toBeTruthy();
});
test('Works with spaces', () => {
expect(isAnagram('rail safety', 'fairy tales')).toBeTruthy();
});
test('Ignores case', () => {
expect(isAnagram('roast beef', 'eat for BSE')).toBeTruthy();
});
test('Ignores special characters', () => {
expect(isAnagram('Regera Dowdy', 'E. G. Deadworry')).toBeTruthy();
});