-
-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: fix tests after updating DatePickerDialogBase to use ShadowDOM
- Loading branch information
Showing
7 changed files
with
130 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
src/__tests__/date-picker-dialog/app-datepicker-dialog-base.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import '../../date-picker-dialog/app-date-picker-dialog-base'; | ||
|
||
import { expect, fixture, html } from '@open-wc/testing'; | ||
import type { TemplateResult } from 'lit'; | ||
|
||
import type { AppDatePickerDialogBase } from '../../date-picker-dialog/app-date-picker-dialog-base'; | ||
import type { AppDatePickerDialogDialog } from '../../date-picker-dialog/app-date-picker-dialog-dialog'; | ||
import { appDatePickerDialogBaseName, appDatePickerDialogDialogName } from '../../date-picker-dialog/constants'; | ||
import { messageFormatter } from '../test-utils/message-formatter'; | ||
|
||
describe(appDatePickerDialogBaseName, () => { | ||
const elementSelectors = { | ||
datePickerDialogDialog: appDatePickerDialogDialogName, | ||
testSlot: '.test', | ||
} as const; | ||
const renderTestSlot = (): TemplateResult => html`<div class=test>Test</div>`; | ||
|
||
type CaseRenders = [boolean, boolean]; | ||
const casesRenders: CaseRenders[] = [ | ||
[false, false], | ||
[true, true], | ||
]; | ||
casesRenders.forEach((a) => { | ||
const [testOpen, expectedHasAssignedElements] = a; | ||
|
||
it( | ||
messageFormatter('renders (open=%s)', a), | ||
async () => { | ||
const el = await fixture<AppDatePickerDialogBase>( | ||
html`<app-date-picker-dialog-base | ||
.open=${testOpen} | ||
>${renderTestSlot()}</app-date-picker-dialog-base>` | ||
); | ||
|
||
const datePickerDialogDialog = el.query<AppDatePickerDialogDialog>( | ||
elementSelectors.datePickerDialogDialog | ||
); | ||
const lightTestSlot = el.querySelector(elementSelectors.testSlot); | ||
const slot = datePickerDialogDialog?.query<HTMLSlotElement>('slot'); | ||
|
||
expect(datePickerDialogDialog).exist; | ||
expect(lightTestSlot).exist; | ||
expect(slot).exist; | ||
|
||
const hasTestSlot = | ||
slot?.assignedElements({ flatten: true }) | ||
.some(n => n.isEqualNode(lightTestSlot)); | ||
|
||
expect(hasTestSlot).equal(expectedHasAssignedElements); | ||
} | ||
) | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters