feat(tests): add fresh-testing-library tests (#1990)

This commit is contained in:
Craig Doremus
2023-11-15 18:25:13 +01:00
committed by GitHub
parent 5d690bede1
commit b5816cd001
20 changed files with 447 additions and 8 deletions
+18 -4
View File
@@ -1,12 +1,21 @@
import { Head } from "$fresh/runtime.ts";
import { useEffect, useRef } from "preact/hooks";
import docsearch from "https://esm.sh/@docsearch/js@3?target=es2020";
export default function SearchButton(props: { class?: string }) {
// Copied from algolia source code
type DocSearchProps = {
appId: string;
apiKey: string;
indexName: string;
container: HTMLElement | string;
};
export default function SearchButton(
props: { docsearch: (args: DocSearchProps) => void; class?: string },
) {
const ref = useRef<HTMLDivElement>(null);
useEffect(() => {
if (ref.current) {
docsearch({
props.docsearch({
appId: "CWUS37S0PK",
apiKey: "caa591b6dcb2c9308551361d954a728b",
indexName: "fresh",
@@ -22,7 +31,12 @@ export default function SearchButton(props: { class?: string }) {
href="/docsearch.css"
/>
</Head>
<div class={"h-9 mb-6 " + (props.class ?? "")} ref={ref}></div>
<div
title="Search Button"
class={"h-9 mb-6 " + (props.class ?? "")}
ref={ref}
>
</div>
</>
);
}