update tests

This commit is contained in:
Yanick Champoux 2023-04-21 11:17:28 -04:00
parent a56fb3e769
commit c45d2abb3c
21 changed files with 39 additions and 5 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 28 KiB

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 36 KiB

After

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 26 KiB

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 27 KiB

After

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 40 KiB

After

Width:  |  Height:  |  Size: 41 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 125 KiB

After

Width:  |  Height:  |  Size: 132 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 70 KiB

After

Width:  |  Height:  |  Size: 71 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 23 KiB

After

Width:  |  Height:  |  Size: 25 KiB

View File

@ -1,21 +1,28 @@
<div class="field label small" class:suffix> <div class="field label small" class:suffix>
<slot> <slot>
<input type="text" bind:value on:change /> <input id={formId} type="text" bind:value on:change />
</slot> </slot>
{#if label} {#if label}
<label class:active>{label}</label> <label for={formId} class:active>{label}</label>
{/if} {/if}
</div> </div>
<script> <script>
import { getContext } from "svelte";
export let label = ""; export let label = "";
export let value = true; export let value = true;
export let placeholder = label; export let placeholder = label;
export let suffix = false; export let suffix = false;
export let activeLabel = undefined; export let activeLabel = undefined;
export let idPrefix = "formId";
$: active = typeof activeLabel === "boolean" ? activeLabel : value; $: active = typeof activeLabel === "boolean" ? activeLabel : value;
const genUid = getContext("genUid") ?? (() => "genUid missing");
const formId = genUid(idPrefix);
</script> </script>
<style> <style>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 23 KiB

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 28 KiB

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 36 KiB

After

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 26 KiB

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 27 KiB

After

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 40 KiB

After

Width:  |  Height:  |  Size: 41 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 125 KiB

After

Width:  |  Height:  |  Size: 132 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 70 KiB

After

Width:  |  Height:  |  Size: 71 KiB

17
src/lib/store/uids.js Normal file
View File

@ -0,0 +1,17 @@
import { writable, get } from "svelte/store";
export default () => {
const store = writable(0);
const genUid = (prefix = "") => {
store.update((x) => x + 1);
return prefix.length
? [prefix, "" + get(store)].join("-")
: "" + get(store);
};
return {
store,
genUid,
};
};

View File

@ -0,0 +1,8 @@
import uids from "./uids";
test("basic", () => {
const { genUid } = uids();
expect(genUid()).toEqual("1");
expect(genUid("potato")).toEqual("potato-2");
});

View File

@ -5,8 +5,10 @@
<script> <script>
import { setContext } from "svelte"; import { setContext } from "svelte";
import { createApi } from "$lib/store/api.ts"; import { createApi } from "$lib/store/api.js";
import uids from "$lib/store/uids.js";
import Layout from "$lib/components/MainLayout.svelte"; import Layout from "$lib/components/MainLayout.svelte";
setContext("api", createApi()); setContext("api", createApi());
setContext("genUid", uids());
</script> </script>

View File

@ -17,9 +17,9 @@ test("we can pass a store", async () => {
api.dispatch.updateIdentification({ shipClass: "Bonobo" }); api.dispatch.updateIdentification({ shipClass: "Bonobo" });
const { getByPlaceholderText } = render(Page, { context }); const { getByLabelText } = render(Page, { context });
const classInput = getByPlaceholderText("ship class"); const classInput = getByLabelText("ship class");
await fireEvent.input(classInput, { target: { value: "Tarzan" } }); await fireEvent.input(classInput, { target: { value: "Tarzan" } });
expect(classInput.value).toEqual("Tarzan"); expect(classInput.value).toEqual("Tarzan");