diff --git a/src/client/controllers/ScheduleController.js b/src/client/controllers/ScheduleController.js index bef86830..7abd5e59 100644 --- a/src/client/controllers/ScheduleController.js +++ b/src/client/controllers/ScheduleController.js @@ -1,7 +1,7 @@ import {populate} from '../../utils/populate'; import {getCourseNameByID} from '../../models/course'; import {indexEquals} from '../../utils/common'; -import {translateAnItem} from '../../utils/common'; +import {selectItem} from '../../utils/common'; function isRequested(period, semester) { return function (schedule) { @@ -24,7 +24,7 @@ export default function (app) { schedules = schedules.map(schedule => { let sem = [['spring', 'Весена'], ['autumn', 'Осень']] - .reduce(translateAnItem( + .reduce(selectItem( i => i[0] === schedule.semester, i => i[1] )); diff --git a/src/utils/common.js b/src/utils/common.js index 72881b1c..a4d014b9 100644 --- a/src/utils/common.js +++ b/src/utils/common.js @@ -39,6 +39,6 @@ export function indexEquals(withNumber) { * @param byCondition * @param map */ -export function translateAnItem(byCondition, map){ +export function selectItem(byCondition, map){ return (result, item) => byCondition(item) ? map(item): map(result) } \ No newline at end of file diff --git a/test/utils/common.js b/test/utils/common.js index cf4a1b20..d6b1fcbf 100644 --- a/test/utils/common.js +++ b/test/utils/common.js @@ -1,18 +1,18 @@ import should from 'should'; -import {translateAnItem} from '../../src/utils/common'; +import {selectItem} from '../../src/utils/common'; describe('utils', () => { describe('common.js', () => { - describe('translateAnItem', () => { + describe('selectItem', () => { let sample = [[1235, 'hello'], [2352, 'banana']]; it('should return a function', () => { - let fn = translateAnItem(); + let fn = selectItem(); fn.should.be.type('function'); }); it('should accept a function as a first parameter and use it as byCondition', () => { - let fn = translateAnItem( + let fn = selectItem( i => i[0] === 2352 && i[1] === 'banana' && i.length === 2, i => i[1] ); @@ -22,7 +22,7 @@ describe('utils', () => { }); it('should accept a function as a second parameter and use it as mapping function', () => { - let fn = translateAnItem( + let fn = selectItem( i => i[0] === 2352, i => i[1] );