Skip to content

Commit

Permalink
test(notification): refactor assertions
Browse files Browse the repository at this point in the history
Co-authored-by: Aykut Saraç <[email protected]>
Signed-off-by: Ogun Babacan <[email protected]>
  • Loading branch information
ogunb and AykutSarac authored Nov 27, 2023
1 parent 4ed0de6 commit da7f9b6
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions src/components/alert/bl-alert.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,14 +153,11 @@ describe("Slot", () => {
);

const actionSlot = el.shadowRoot!.querySelector('slot[name="action"]') as HTMLSlotElement;
const actionElement = actionSlot?.assignedElements()[0] as HTMLElement;
const [actionElement, actionSpanElement] = actionSlot?.assignedElements();

Check failure on line 156 in src/components/alert/bl-alert.test.ts

View workflow job for this annotation

GitHub Actions / verify / verify

Unsafe usage of optional chaining. If it short-circuits with 'undefined' the evaluation will throw TypeError

expect(actionElement).to.exist;
expect(actionElement as HTMLElement).to.exist;
expect(actionElement.tagName).to.eq("BL-BUTTON");

const actionSpanElement = actionSlot?.assignedElements()[1] as HTMLElement;

expect(actionSpanElement).to.not.exist;
expect(actionSpanElement as HTMLElement).to.not.exist;

const actionSecondarySlot = el.shadowRoot!.querySelector(
'slot[name="action-secondary"]'
Expand Down

0 comments on commit da7f9b6

Please sign in to comment.