Skip to content

Commit

Permalink
Replace test to use iconSpy (#3123)
Browse files Browse the repository at this point in the history
  • Loading branch information
adi-unni authored Apr 9, 2024
1 parent 6979a3e commit 04074df
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/components/external-link/_macro.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import * as cheerio from 'cheerio';

import axe from '../../tests/helpers/axe';
import { renderComponent } from '../../tests/helpers/rendering';
import { renderComponent, templateFaker } from '../../tests/helpers/rendering';

const EXAMPLE_EXTERNAL_LINK = {
url: 'http://example.com',
Expand Down Expand Up @@ -69,9 +69,14 @@ describe('macro: external-link', () => {
});

it('has an "external-link" icon', async () => {
const $ = cheerio.load(renderComponent('external-link', EXAMPLE_EXTERNAL_LINK));
const faker = templateFaker();
const iconsSpy = faker.spy('icon');

faker.renderComponent('external-link', {
...EXAMPLE_EXTERNAL_LINK,
newWindowDescription: 'custom opens in a new tab text',
});

const $svg = $('.ons-external-link__icon svg');
expect($svg.length).toBe(1);
expect(iconsSpy.occurrences[0].iconType).toBe('external-link');
});
});

0 comments on commit 04074df

Please sign in to comment.