mirror of
https://seed.radicle.dev/rad:z4V1sjrXqjvFdnCUbxPFqd5p4DtH5.git
synced 2026-11-29 18:20:30 +08:00
Improve testing suite
Signed-off-by: Sebastian Martinez <sebastinez@me.com>
This commit is contained in:
+23
-11
@@ -1,18 +1,30 @@
|
||||
import Search from "./Search.svelte";
|
||||
import { mount } from "radicle-svelte-unit-test";
|
||||
import { styles } from "@test/support/index";
|
||||
import { fireEvent, render } from "@testing-library/svelte";
|
||||
import "@public/index.css";
|
||||
|
||||
describe('Search', function () {
|
||||
it("Renders correctly", () => {
|
||||
mount(Search, {}, styles);
|
||||
cy.get("input").should("exist");
|
||||
describe('Logic', () => {
|
||||
it("show a appropiate placeholder", () => {
|
||||
render(Search);
|
||||
cy.get("input").should("have.attr", "placeholder", "Search a name or address...");
|
||||
});
|
||||
|
||||
it("Search input displays and navigates correctly", () => {
|
||||
mount(Search, {}, styles);
|
||||
cy.get("input").type("cloudhead{enter}");
|
||||
cy.get("input").should("have.value", "cloudhead");
|
||||
cy.url().should("contain", "/resolver/query?q=cloudhead");
|
||||
it("allow input a query and navigates accordingly", () => {
|
||||
render(Search);
|
||||
cy.get("input").type("cloudhead.radicle.eth{enter}");
|
||||
cy.get("input").should("have.value", "cloudhead.radicle.eth");
|
||||
cy.url().should("contain", "/resolver/query?q=cloudhead.radicle.eth");
|
||||
});
|
||||
});
|
||||
|
||||
describe("Events", () => {
|
||||
it("should fire an event when the input changes", () => {
|
||||
const { component } = render(Search);
|
||||
const mock = cy.spy();
|
||||
component.$on("search", mock);
|
||||
|
||||
cy.get("input").then(([input]) => {
|
||||
fireEvent.keyDown(input, { key: "Enter" });
|
||||
expect(mock).to.have.been.calledOnce;
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user