mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2026-03-17 21:13:48 +00:00
Replaced test by it in tests
This commit is contained in:
@@ -45,7 +45,7 @@ describe('<Overview />', () => {
|
|||||||
|
|
||||||
afterEach(() => wrapper?.unmount());
|
afterEach(() => wrapper?.unmount());
|
||||||
|
|
||||||
test('cards display loading messages when still loading', () => {
|
it('displays loading messages when still loading', () => {
|
||||||
const wrapper = createWrapper(true);
|
const wrapper = createWrapper(true);
|
||||||
const cards = wrapper.find(CardText);
|
const cards = wrapper.find(CardText);
|
||||||
|
|
||||||
@@ -53,7 +53,7 @@ describe('<Overview />', () => {
|
|||||||
cards.forEach((card) => expect(card.html()).toContain('Loading...'));
|
cards.forEach((card) => expect(card.html()).toContain('Loading...'));
|
||||||
});
|
});
|
||||||
|
|
||||||
test('amounts are displayed in cards after finishing loading', () => {
|
it('displays amounts in cards after finishing loading', () => {
|
||||||
const wrapper = createWrapper();
|
const wrapper = createWrapper();
|
||||||
const cards = wrapper.find(CardText);
|
const cards = wrapper.find(CardText);
|
||||||
|
|
||||||
@@ -64,21 +64,21 @@ describe('<Overview />', () => {
|
|||||||
expect(cards.at(3).html()).toContain(prettify(3));
|
expect(cards.at(3).html()).toContain(prettify(3));
|
||||||
});
|
});
|
||||||
|
|
||||||
test('first card displays warning for old shlink versions', () => {
|
it('displays warning in first card for old shlink versions', () => {
|
||||||
const wrapper = createWrapper();
|
const wrapper = createWrapper();
|
||||||
const firstCard = wrapper.find(CardText).first();
|
const firstCard = wrapper.find(CardText).first();
|
||||||
|
|
||||||
expect(firstCard.html()).toContain('Shlink 2.2 is needed');
|
expect(firstCard.html()).toContain('Shlink 2.2 is needed');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('nests complex components', () => {
|
it('nests complex components', () => {
|
||||||
const wrapper = createWrapper();
|
const wrapper = createWrapper();
|
||||||
|
|
||||||
expect(wrapper.find(CreateShortUrl)).toHaveLength(1);
|
expect(wrapper.find(CreateShortUrl)).toHaveLength(1);
|
||||||
expect(wrapper.find(ShortUrlsTable)).toHaveLength(1);
|
expect(wrapper.find(ShortUrlsTable)).toHaveLength(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('links to other sections are displayed', () => {
|
it('displays links to other sections', () => {
|
||||||
const wrapper = createWrapper();
|
const wrapper = createWrapper();
|
||||||
const links = wrapper.find(Link);
|
const links = wrapper.find(Link);
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ describe('<CopyToClipboardIcon />', () => {
|
|||||||
});
|
});
|
||||||
afterEach(() => wrapper?.unmount());
|
afterEach(() => wrapper?.unmount());
|
||||||
|
|
||||||
test('expected components are wrapped', () => {
|
it('wraps expected components', () => {
|
||||||
const copyToClipboard = wrapper.find(CopyToClipboard);
|
const copyToClipboard = wrapper.find(CopyToClipboard);
|
||||||
const icon = wrapper.find(FontAwesomeIcon);
|
const icon = wrapper.find(FontAwesomeIcon);
|
||||||
|
|
||||||
|
|||||||
@@ -14,13 +14,13 @@ describe('<DateIntervalDropdownItems />', () => {
|
|||||||
afterEach(jest.clearAllMocks);
|
afterEach(jest.clearAllMocks);
|
||||||
afterEach(() => wrapper?.unmount());
|
afterEach(() => wrapper?.unmount());
|
||||||
|
|
||||||
test('expected amount of items is rendered', () => {
|
it('renders expected amount of items', () => {
|
||||||
const items = wrapper.find(DropdownItem);
|
const items = wrapper.find(DropdownItem);
|
||||||
|
|
||||||
expect(items).toHaveLength(DATE_INTERVALS.length);
|
expect(items).toHaveLength(DATE_INTERVALS.length);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('expected item is active', () => {
|
it('sets expected item as active', () => {
|
||||||
const items = wrapper.find(DropdownItem);
|
const items = wrapper.find(DropdownItem);
|
||||||
const EXPECTED_ACTIVE_INDEX = 5;
|
const EXPECTED_ACTIVE_INDEX = 5;
|
||||||
|
|
||||||
@@ -28,7 +28,7 @@ describe('<DateIntervalDropdownItems />', () => {
|
|||||||
items.forEach((item, index) => expect(item.prop('active')).toEqual(index === EXPECTED_ACTIVE_INDEX));
|
items.forEach((item, index) => expect(item.prop('active')).toEqual(index === EXPECTED_ACTIVE_INDEX));
|
||||||
});
|
});
|
||||||
|
|
||||||
test('selecting an element triggers onChange callback', () => {
|
it('triggers onChange callback when selecting an element', () => {
|
||||||
const items = wrapper.find(DropdownItem);
|
const items = wrapper.find(DropdownItem);
|
||||||
|
|
||||||
items.at(2).simulate('click');
|
items.at(2).simulate('click');
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ describe('<DateIntervalSelector />', () => {
|
|||||||
});
|
});
|
||||||
afterEach(() => wrapper?.unmount());
|
afterEach(() => wrapper?.unmount());
|
||||||
|
|
||||||
test('props are passed down to nested DateIntervalDropdownItems', () => {
|
it('passes props down to nested DateIntervalDropdownItems', () => {
|
||||||
const items = wrapper.find(DateIntervalDropdownItems);
|
const items = wrapper.find(DateIntervalDropdownItems);
|
||||||
const dropdown = wrapper.find(DropdownBtn);
|
const dropdown = wrapper.find(DropdownBtn);
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ describe('<DateRangeSelector />', () => {
|
|||||||
afterEach(jest.clearAllMocks);
|
afterEach(jest.clearAllMocks);
|
||||||
afterEach(() => wrapper?.unmount());
|
afterEach(() => wrapper?.unmount());
|
||||||
|
|
||||||
test('proper amount of items is rendered', () => {
|
it('renders proper amount of items', () => {
|
||||||
const wrapper = createWrapper();
|
const wrapper = createWrapper();
|
||||||
const items = wrapper.find(DropdownItem);
|
const items = wrapper.find(DropdownItem);
|
||||||
const dateIntervalItems = wrapper.find(DateIntervalDropdownItems);
|
const dateIntervalItems = wrapper.find(DateIntervalDropdownItems);
|
||||||
@@ -31,7 +31,7 @@ describe('<DateRangeSelector />', () => {
|
|||||||
expect(items.filter('[active]')).toHaveLength(1);
|
expect(items.filter('[active]')).toHaveLength(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
test.each([
|
it.each([
|
||||||
[ undefined, 1, 0 ],
|
[ undefined, 1, 0 ],
|
||||||
[ 'today' as DateInterval, 0, 1 ],
|
[ 'today' as DateInterval, 0, 1 ],
|
||||||
[ 'yesterday' as DateInterval, 0, 1 ],
|
[ 'yesterday' as DateInterval, 0, 1 ],
|
||||||
@@ -41,7 +41,7 @@ describe('<DateRangeSelector />', () => {
|
|||||||
[ 'last180days' as DateInterval, 0, 1 ],
|
[ 'last180days' as DateInterval, 0, 1 ],
|
||||||
[ 'last365Days' as DateInterval, 0, 1 ],
|
[ 'last365Days' as DateInterval, 0, 1 ],
|
||||||
[{ startDate: moment() }, 0, 0 ],
|
[{ startDate: moment() }, 0, 0 ],
|
||||||
])('proper element is active based on provided date range', (
|
])('sets proper element as active based on provided date range', (
|
||||||
initialDateRange,
|
initialDateRange,
|
||||||
expectedActiveItems,
|
expectedActiveItems,
|
||||||
expectedActiveIntervalItems,
|
expectedActiveIntervalItems,
|
||||||
@@ -56,7 +56,7 @@ describe('<DateRangeSelector />', () => {
|
|||||||
expect(dateIntervalItems).toHaveLength(expectedActiveIntervalItems);
|
expect(dateIntervalItems).toHaveLength(expectedActiveIntervalItems);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('selecting an element triggers onDatesChange callback', () => {
|
it('triggers onDatesChange callback when selecting an element', () => {
|
||||||
const wrapper = createWrapper();
|
const wrapper = createWrapper();
|
||||||
const item = wrapper.find(DropdownItem).at(0);
|
const item = wrapper.find(DropdownItem).at(0);
|
||||||
const dateIntervalItems = wrapper.find(DateIntervalDropdownItems);
|
const dateIntervalItems = wrapper.find(DateIntervalDropdownItems);
|
||||||
|
|||||||
Reference in New Issue
Block a user