diff --git a/src/components/button/_macro.spec.js b/src/components/button/_macro.spec.js index 2936e3aef2..9bef556773 100644 --- a/src/components/button/_macro.spec.js +++ b/src/components/button/_macro.spec.js @@ -149,6 +149,21 @@ describe('FOR: Macro: Button', () => { }); }); + describe('GIVEN: Params: iconType', () => { + describe('WHEN: iconType parameter is provided', () => { + test('THEN: the button has an svg element', () => { + const $ = cheerio.load( + renderComponent('button', { + text: 'Click me!', + iconPosition: 'after', + iconType: 'exit', + }), + ); + expect($('svg').length).toBe(1); + }); + }); + }); + describe('GIVEN: Params: variants', () => { describe('WHEN: variants are present', () => { test('THEN: the button has the expected variant classes', () => { @@ -419,7 +434,7 @@ describe('FOR: Macro: Button', () => { describe('GIVEN: Params: noIcon', () => { describe('WHEN: noIcon is set to true', () => { - test('THEN: button does not have the default arrow-next icon', () => { + test('THEN: the button does not have the default arrow-next icon', () => { const faker = templateFaker(); const iconsSpy = faker.spy('icon'); @@ -432,7 +447,7 @@ describe('FOR: Macro: Button', () => { }); }); describe('WHEN: noIcon is set to false', () => { - test('THEN: button has the default arrow-next icon', () => { + test('THEN: the button has the default arrow-next icon', () => { const faker = templateFaker(); const iconsSpy = faker.spy('icon'); @@ -445,4 +460,27 @@ describe('FOR: Macro: Button', () => { }); }); }); + + describe('GIVEN: Params: listeners', () => { + describe('WHEN: listeners are provided', () => { + test('THEN: the button renders each listener', () => { + const $ = cheerio.load( + renderComponent('button', { + id: 'example-id', + listeners: { + click: `alert('Input was clicked')`, + keypress: `alert('Key was pressed')`, + }, + }), + ); + const script = $('script').html(); + expect(script).toContain( + `document.getElementById("example-id").addEventListener('click', function(){ alert('Input was clicked') });`, + ); + expect(script).toContain( + `document.getElementById("example-id").addEventListener('keypress', function(){ alert('Key was pressed') });`, + ); + }); + }); + }); });