Skip to content

Commit

Permalink
Fixed tests relating to the new version of the name of buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
rob-baillie-ortoo committed Jan 11, 2022
1 parent b283f97 commit c5a1dd5
Showing 1 changed file with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ describe('c-confirmation-dialog', () => {
const expectedElement = element.shadowRoot.querySelector( 'c-modal div[slot="footer"]' );
expect( expectedElement ).not.toBe( null );

expect( expectedElement.querySelector( '[data-name="confirm"]' ).title ).not.toBe( null );
expect( expectedElement.querySelector( '[data-name="confirm"]' ).label ).not.toBe( null );
expect( expectedElement.querySelector( '[data-name="cancel"]' ).title ).not.toBe( null );
expect( expectedElement.querySelector( '[data-name="cancel"]' ).label ).not.toBe( null );
expect( expectedElement.querySelector( '[data-ortoo-elem-id="confirmation-confirm"]' ).title ).not.toBe( null );
expect( expectedElement.querySelector( '[data-ortoo-elem-id="confirmation-confirm"]' ).label ).not.toBe( null );
expect( expectedElement.querySelector( '[data-ortoo-elem-id="confirmation-cancel"]' ).title ).not.toBe( null );
expect( expectedElement.querySelector( '[data-ortoo-elem-id="confirmation-cancel"]' ).label ).not.toBe( null );
});

it('When set to visible, contains a div containing cancel and confirm buttons with the specified labels, directing them to the modal footer slot', () => {
Expand All @@ -64,10 +64,10 @@ describe('c-confirmation-dialog', () => {
const expectedElement = element.shadowRoot.querySelector( 'c-modal div[slot="footer"]' );
expect( expectedElement ).not.toBe( null );

expect( expectedElement.querySelector( '[data-name="confirm"]' ).title ).toBe( 'Confirm thing' );
expect( expectedElement.querySelector( '[data-name="confirm"]' ).label ).toBe( 'Confirm thing' );
expect( expectedElement.querySelector( '[data-name="cancel"]' ).title ).toBe( 'Cancel thing' );
expect( expectedElement.querySelector( '[data-name="cancel"]' ).label ).toBe( 'Cancel thing' );
expect( expectedElement.querySelector( '[data-ortoo-elem-id="confirmation-confirm"]' ).title ).toBe( 'Confirm thing' );
expect( expectedElement.querySelector( '[data-ortoo-elem-id="confirmation-confirm"]' ).label ).toBe( 'Confirm thing' );
expect( expectedElement.querySelector( '[data-ortoo-elem-id="confirmation-cancel"]' ).title ).toBe( 'Cancel thing' );
expect( expectedElement.querySelector( '[data-ortoo-elem-id="confirmation-cancel"]' ).label ).toBe( 'Cancel thing' );
});

it('When set to visible and passed a valid type, contains a div containing cancel and confirm buttons with the specified labels, directing them to the modal footer slot', () => {
Expand All @@ -81,8 +81,8 @@ describe('c-confirmation-dialog', () => {
const expectedElement = element.shadowRoot.querySelector( 'c-modal div[slot="footer"]' );
expect( expectedElement ).not.toBe( null );

expect( expectedElement.querySelector( '[data-name="confirm"]' ).label ).not.toBe( null );
expect( expectedElement.querySelector( '[data-name="cancel"]' ).label ).not.toBe( null );
expect( expectedElement.querySelector( '[data-ortoo-elem-id="confirmation-confirm"]' ).label ).not.toBe( null );
expect( expectedElement.querySelector( '[data-ortoo-elem-id="confirmation-cancel"]' ).label ).not.toBe( null );
});

it('When set to an invalid type, will throw an error', () => {
Expand Down Expand Up @@ -113,7 +113,7 @@ describe('c-confirmation-dialog', () => {
const cancelHandler = jest.fn();
element.addEventListener( 'cancel', cancelHandler ) ;

element.shadowRoot.querySelector( '[data-name="confirm"]' ).click();
element.shadowRoot.querySelector( '[data-ortoo-elem-id="confirmation-confirm"]' ).click();

expect( confirmHandler ).toHaveBeenCalled();
expect( confirmHandler.mock.calls[0][0].detail ).toBe( CONFIRM_MESSAGE );
Expand Down Expand Up @@ -142,7 +142,7 @@ describe('c-confirmation-dialog', () => {
const cancelHandler = jest.fn();
element.addEventListener( 'cancel', cancelHandler ) ;

element.shadowRoot.querySelector( '[data-name="cancel"]' ).click();
element.shadowRoot.querySelector( '[data-ortoo-elem-id="confirmation-cancel"]' ).click();

expect( cancelHandler ).toHaveBeenCalled();
expect( cancelHandler.mock.calls[0][0].detail ).toBe( CANCEL_MESSAGE );
Expand Down

0 comments on commit c5a1dd5

Please sign in to comment.