-
Notifications
You must be signed in to change notification settings - Fork 78
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: Update tests to use common test and apply correct default display. #3778
Changes from 3 commits
d2e49ee
a59fbd2
3e119e3
11cf67a
8cbdf52
03bcdac
68e3554
0902327
7d9ed8e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
:host { | ||
@apply block; | ||
} | ||
|
||
:host([scale="s"]) { | ||
.controls-wrapper { | ||
@apply h-6; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
:host { | ||
@apply block; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @eriklharper what display should this component have? Should it be "block"? Seems like its already block now but I'm not sure why. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If I change this to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I do agree that both of these should probably be inline-block like their native counterparts. However, I didn't want to break screener tests and user apps. So this would likely be a breaking change. |
||
} | ||
|
||
// scales | ||
:host([scale="s"]) { | ||
& input, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,6 +45,10 @@ $loader-circumference: ($loader-scale - (2 * $stroke-width)) * 3.14159; | |
@apply py-0; | ||
} | ||
|
||
:host { | ||
@apply hidden; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. loader should be hidden by default and displayed when active. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sort of a separate discussion, but maybe we should use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Its a separate discussion but by default the loader is not shown until it has an active attribute/property. We can evaluate changing this so that the active property is not necessary and just remove it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
} | ||
|
||
:host([active]) { | ||
@apply flex; | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
:host { | ||
@apply inline-block w-auto align-middle; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Copied this from There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should the non-display styles be set on the container instead? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That looks right since the native There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Good question. I think the display should probably be set on the host element, but as far as the other properties, there's probably a lot you can move to a container div, unless the host needs like a position property or some other parent-child css property that enables styles to work for elements underneath the host element, like flex for example. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll remove the width and align stuff. |
||
} | ||
|
||
:host { | ||
.split-button__container { | ||
@apply flex items-stretch; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,5 @@ | ||
import { newE2EPage } from "@stencil/core/testing"; | ||
import { HYDRATED_ATTR } from "../../tests/commonTests"; | ||
import { renders } from "../../tests/commonTests"; | ||
|
||
describe("calcite-stepper-item", () => { | ||
it("renders", async () => { | ||
const page = await newE2EPage(); | ||
|
||
await page.setContent("<calcite-stepper-item></calcite-stepper-item>"); | ||
const element = await page.find("calcite-stepper-item"); | ||
expect(element).toHaveAttribute(HYDRATED_ATTR); | ||
}); | ||
it("renders", () => renders("calcite-stepper-item", { display: "flex" })); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,12 @@ | ||
import { newE2EPage } from "@stencil/core/testing"; | ||
import { defaults, HYDRATED_ATTR } from "../../tests/commonTests"; | ||
import { defaults, renders } from "../../tests/commonTests"; | ||
|
||
describe("calcite-tab", () => { | ||
const tabHtml = "<calcite-tab>A tab</calcite-tab>"; | ||
|
||
it("renders", async () => { | ||
const page = await newE2EPage({ html: tabHtml }); | ||
const element = await page.find("calcite-tab"); | ||
const styles = await element.getComputedStyle(); | ||
expect(element).toHaveAttribute(HYDRATED_ATTR); | ||
expect(styles["display"]).toEqual("none"); | ||
expect(styles["visibility"]).toEqual("visible"); | ||
}); | ||
it("renders", () => renders("calcite-tab", { display: "none", visible: false })); | ||
|
||
it("renders: active", () => renders("<calcite-tab active></calcite-tab>", { display: "block", visible: true })); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's try to group related tests whenever possible w/ |
||
|
||
it("has defaults", async () => | ||
defaults("calcite-tab", [ | ||
|
@@ -20,13 +15,6 @@ describe("calcite-tab", () => { | |
{ propertyName: "scale", defaultValue: undefined } | ||
])); | ||
|
||
it("has block display when active", async () => { | ||
const page = await newE2EPage({ html: "<calcite-tab active></calcite-tab>" }); | ||
const element = await page.find("calcite-tab"); | ||
const styles = await element.getComputedStyle(); | ||
expect(styles["display"]).toEqual("block"); | ||
}); | ||
|
||
describe("when nested within calcite-tabs component", () => { | ||
it("should render with medium scale", async () => { | ||
const page = await newE2EPage({ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@eriklharper is this correct? seems input is block.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would advocate
inline-block
for this too.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I change this to
inline-block
the screener tests will change due to width differences. I will leave as now. If you think it should be changed I think a different issue is needed.