Test migration to jest by hand
Apparently using regular expressions is way easier.
This commit is contained in:
6
test/lcm/lcm.js
Normal file
6
test/lcm/lcm.js
Normal file
@ -0,0 +1,6 @@
|
||||
const lcm = (...arr) => {
|
||||
const gcd = (x, y) => (!y ? x : gcd(y, x % y));
|
||||
const _lcm = (x, y) => x * y / gcd(x, y);
|
||||
return [...arr].reduce((a, b) => _lcm(a, b));
|
||||
};
|
||||
module.exports = lcm;
|
||||
10
test/lcm/lcm.test.js
Normal file
10
test/lcm/lcm.test.js
Normal file
@ -0,0 +1,10 @@
|
||||
const expect = require('expect');
|
||||
const lcm = require('./lcm.js');
|
||||
|
||||
|
||||
test('lcm is a Function', () => {
|
||||
expect(lcm).toBeInstanceOf(Function);
|
||||
});
|
||||
t.equal(lcm(12, 7), 84, "Returns the least common multiple of two or more numbers.");
|
||||
t.equal(lcm(...[1, 3, 4, 5]), 60, "Returns the least common multiple of two or more numbers.");
|
||||
|
||||
Reference in New Issue
Block a user