Created rangeOf helper function which does a range + map

This commit is contained in:
Alejandro Celaya
2019-03-09 12:19:33 +01:00
parent 60576388c5
commit 83704ca4b5
6 changed files with 45 additions and 11 deletions

View File

@@ -3,7 +3,12 @@ import L from 'leaflet';
import marker2x from 'leaflet/dist/images/marker-icon-2x.png';
import marker from 'leaflet/dist/images/marker-icon.png';
import markerShadow from 'leaflet/dist/images/marker-shadow.png';
import { stateFlagTimeout as stateFlagTimeoutFactory, determineOrderDir, fixLeafletIcons } from '../../src/utils/utils';
import {
stateFlagTimeout as stateFlagTimeoutFactory,
determineOrderDir,
fixLeafletIcons,
rangeOf,
} from '../../src/utils/utils';
describe('utils', () => {
describe('stateFlagTimeout', () => {
@@ -57,4 +62,29 @@ describe('utils', () => {
expect(shadowUrl).toEqual(markerShadow);
});
});
describe('rangeOf', () => {
const func = (i) => `result_${i}`;
const size = 5;
it('builds a range of specified size invike provided function', () => {
expect(rangeOf(size, func)).toEqual([
'result_1',
'result_2',
'result_3',
'result_4',
'result_5',
]);
});
it('builds a range starting at provided pos', () => {
const startAt = 3;
expect(rangeOf(size, func, startAt)).toEqual([
'result_3',
'result_4',
'result_5',
]);
});
});
});