tests ES6 refactoring, tests update, + common.js tests

This commit is contained in:
tmshv committed 2016-02-22 03:53:11 +03:00
1 parent ae11dc5235
commit 766105afac
6 files changed
+58 -43

No files matched your search

+35
View File
@@ -0,0 +1,35 @@
import should from 'should';
import {translateAnItem} from '../../src/utils/common';
describe('utils', () => {
describe('common.js', () => {
describe('translateAnItem', () => {
let sample = [[1235, 'hello'], [2352, 'banana']];
it('should return a function', () => {
let fn = translateAnItem();
fn.should.be.type('function');
});
it('should accept a function as a first parameter and use it as byCondition', () => {
let fn = translateAnItem(
i => i[0] === 2352 && i[1] === 'banana' && i.length === 2,
i => i[1]
);
let result = sample.reduce(fn);
result.should.be.equal('banana');
});
it('should accept a function as a second parameter and use it as mapping function', () => {
let fn = translateAnItem(
i => i[0] === 2352,
i => i[1]
);
let result = sample.reduce(fn);
result.should.be.equal('banana');
});
});
});
});