mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2026-04-19 13:06:22 +00:00
Created rangeOf helper function which does a range + map
This commit is contained in:
@@ -1,10 +1,11 @@
|
||||
import React from 'react';
|
||||
import { shallow } from 'enzyme';
|
||||
import { identity, range } from 'ramda';
|
||||
import { identity } from 'ramda';
|
||||
import * as sinon from 'sinon';
|
||||
import createTagsList from '../../src/tags/TagsList';
|
||||
import MuttedMessage from '../../src/utils/MuttedMessage';
|
||||
import SearchField from '../../src/utils/SearchField';
|
||||
import { rangeOf } from '../../src/utils/utils';
|
||||
|
||||
describe('<TagsList />', () => {
|
||||
let wrapper;
|
||||
@@ -53,7 +54,7 @@ describe('<TagsList />', () => {
|
||||
it('renders the proper amount of groups and cards based on the amount of tags', () => {
|
||||
const amountOfTags = 10;
|
||||
const amountOfGroups = 4;
|
||||
const wrapper = createWrapper({ filteredTags: range(0, amountOfTags).map((i) => `tag_${i}`) });
|
||||
const wrapper = createWrapper({ filteredTags: rangeOf(amountOfTags, (i) => `tag_${i}`) });
|
||||
const cards = wrapper.find(TagCard);
|
||||
const groups = wrapper.find('.col-md-6');
|
||||
|
||||
|
||||
@@ -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',
|
||||
]);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user