Skip to content

Commit

Permalink
Added icon unit tests and additional storybook (#3988)
Browse files Browse the repository at this point in the history
  • Loading branch information
tjleing authored and jordanranz committed Dec 31, 2019
1 parent 228f056 commit d0f980a
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,26 @@ async function snapshotTestIcon(iconName: string) {
expect(page.root).toMatchSnapshot();
}

async function snapshotOverrideTestIcon(iconName: string) {
const page = await newSpecPage({
components: [AmplifyIcon],
html: `<amplify-icon name='${iconName}' override-style='true'></amplify-icon>`,
});

expect(page.root).toMatchSnapshot();
}

/** Tests */
describe('amplify-icon spec:', () => {
describe('Render logic ->', () => {
Object.keys(icons).map(name => {
it(`renders ${name} correctly`, async () => snapshotTestIcon(name));
});
});
describe('Component logic ->', () => {
it(`has overrideStyle false by default`, async () => {
const icon = new AmplifyIcon();
expect(icon.overrideStyle).toBe(false);
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,16 @@ amplifyIcon.add('with icon', () => {

const name = select(label, iconNames, defaultValue);

return `<amplify-icon name="${name}"></amplify-icon>`;
return `<amplify-icon override-style="true" name="${name}"></amplify-icon>`;
});

amplifyIcon.add('with two icons', () => {
const label = 'Icon Name';
const iconNames = Object.keys(icons);
const defaultValue = 'sound-mute';

const name1 = select(label, iconNames, defaultValue);
const name2 = select("test", ['sound-mute', 'sound'], 'sound');

return `<div><amplify-icon override-style="true" name="${name1}"></amplify-icon><amplify-icon override-style="true" name="${name2}"></amplify-icon></div>`;
});

0 comments on commit d0f980a

Please sign in to comment.