-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add CodeSandbox molecule and storybook interaction
- Loading branch information
Showing
8 changed files
with
114 additions
and
5 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
57 changes: 57 additions & 0 deletions
57
docs/.vitepress/theme/molecules/codesandbox/CodeSandbox.spec.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,57 @@ | ||
import CodeSandbox from "./CodeSandbox.vue"; | ||
import {render, screen} from "@testing-library/vue"; | ||
import VPButton from "../../../../../.storybook/mock/VPButton.vue"; | ||
import {expect, waitFor} from "@storybook/test"; | ||
|
||
describe("<CodeSandbox />", () => { | ||
it("should render CodeSandbox component", async () => { | ||
render(CodeSandbox, { | ||
props: { | ||
sandboxId: "abc123" | ||
}, | ||
global: { | ||
stubs: { | ||
VPButton: VPButton | ||
} | ||
} | ||
}); | ||
|
||
expect(screen.getByRole("button")).toHaveTextContent("Start sandbox"); | ||
|
||
screen.getByRole("button").click(); | ||
|
||
const iframe = await waitFor(() => { | ||
return screen.getByTestId("iframe-sandbox"); | ||
}); | ||
|
||
await expect(iframe).toHaveAttribute("src", expect.stringContaining("sandbox")); | ||
}); | ||
it("should render CodeSandbox component with all props", async () => { | ||
render(CodeSandbox, { | ||
props: { | ||
sandboxId: "abc123", | ||
fontSize: 12, | ||
hideNavigation: 0, | ||
theme: "light" | ||
}, | ||
global: { | ||
stubs: { | ||
VPButton: VPButton | ||
} | ||
} | ||
}); | ||
|
||
expect(screen.getByRole("button")).toHaveTextContent("Start sandbox"); | ||
|
||
screen.getByRole("button").click(); | ||
|
||
const iframe = await waitFor(() => { | ||
return screen.getByTestId("iframe-sandbox"); | ||
}); | ||
|
||
await expect(iframe).toHaveAttribute( | ||
"src", | ||
"https://codesandbox.io/embed/abc123?fontsize=12&hidenavigation=0&theme=light" | ||
); | ||
}); | ||
}); |
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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