-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
76 additions
and
17 deletions.
There are no files selected for viewing
69 changes: 60 additions & 9 deletions
69
src/components/calcite-color-picker/calcite-color-picker.e2e.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 |
---|---|---|
@@ -1,19 +1,70 @@ | ||
import { defaults, renders } from "../../tests/commonTests"; | ||
|
||
import { | ||
CSS, | ||
DEFAULT_HEX_COLOR, | ||
DEFAULT_STORAGE_KEY_PREFIX | ||
} from "./resources"; | ||
import { newE2EPage } from "@stencil/core/testing"; | ||
|
||
describe("my-component", () => { | ||
it("renders", async () => { | ||
describe("calcite-color-picker", () => { | ||
it("renders", async () => renders("calcite-color-picker")); | ||
|
||
it("has a default color", async () => | ||
defaults("calcite-color-picker", [ | ||
{ | ||
propertyName: "value", | ||
defaultValue: DEFAULT_HEX_COLOR | ||
} | ||
])); | ||
|
||
it("emits color selection change", async () => { | ||
const page = await newE2EPage(); | ||
await page.setContent("<calcite-color-picker></calcite-color-picker>"); | ||
const picker = await page.find("calcite-color-picker"); | ||
|
||
await page.setContent("<my-component></my-component>"); | ||
const element = await page.find("my-component"); | ||
expect(element).toHaveClass("hydrated"); | ||
const spy = await picker.spyOnEvent("calciteColorPickerColorChange"); | ||
|
||
picker.setProperty("value", "#FF00FF"); | ||
await page.waitForChanges(); | ||
|
||
expect(spy).toHaveReceivedEventTimes(1); | ||
}); | ||
|
||
it.skip("has a default color", async () => {}); | ||
it("it allows saving unique colors", async () => { | ||
const page = await newE2EPage(); | ||
await page.setContent( | ||
`<calcite-color-picker></calcite-color-picker>` | ||
); | ||
|
||
it.skip("emits color selection change", async () => {}); | ||
const picker = await page.find("calcite-color-picker"); | ||
const saveColor = await page.find( | ||
`calcite-color-picker >>> .${CSS.saveColor}` | ||
); | ||
await saveColor.click(); | ||
|
||
it.skip("uses local storage to keep colors", async () => {}); | ||
const color1 = "#FF00FF"; | ||
const color2 = "#BEEFEE"; | ||
|
||
it.skip("uses local storage to keep colors", async () => {}); | ||
picker.setProperty("value", color1); | ||
await page.waitForChanges(); | ||
await saveColor.click(); | ||
|
||
picker.setProperty("value", color2); | ||
await page.waitForChanges(); | ||
await saveColor.click(); | ||
|
||
picker.setProperty("value", color1); | ||
await page.waitForChanges(); | ||
await saveColor.click(); | ||
|
||
picker.setProperty("value", color2); | ||
await page.waitForChanges(); | ||
await saveColor.click(); | ||
|
||
const savedColors = await page.findAll( | ||
`calcite-color-picker >>> .${CSS.savedColors} calcite-color-swatch` | ||
); | ||
expect(savedColors).toHaveLength(3); | ||
}); | ||
}); |
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