import { $, component$ } from "@builder.io/qwik";
import { QwikCityMockProvider } from "@builder.io/qwik-city";
import { ExampleTest } from "./example";
import { useExampleLoader } from "../../loaders/example.loader";
import { useExampleAction } from "../../actions/example.action";
const Template = component$((props: { flag: boolean }) => {
const loadersMock = [
{
loader: useExampleLoader,
data: "Loader Data",
},
];
const actionStub = $(() => cy.stub().as("actionStub"))();
const actionsMock = [
{
action: useExampleAction,
handler: $(async () => {
await actionStub.then((_) => _());
return { status: 200, result: "Action Data" };
}),
},
];
return (
);
});
it("should render ⭐", () => {
cy.mount();
cy.get("#icon").should("contain.text", "⭐");
});
it("should render 💣", () => {
cy.mount();
cy.get("#icon").should("contain.text", "💣");
});
it("should count clicks", () => {
cy.mount();
cy.get("#count").should("contain.text", "Count:0");
cy.get("#btn-counter").click();
cy.get("#count").should("contain.text", "Count:1");
});
it("should render loader data", () => {
cy.mount();
cy.get("#loader-data").should("contain.text", "Loader Data");
});
it("should call action on button click", () => {
cy.mount();
cy.get("#btn-action").click();
cy.get("@actionStub").should("have.been.called");
});