Skip to content

Commit

Permalink
test: setting up base test files for all existing components
Browse files Browse the repository at this point in the history
  • Loading branch information
daenub committed Sep 28, 2023
1 parent 5e93c48 commit e24d6d0
Show file tree
Hide file tree
Showing 4 changed files with 125 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/components/input/test/input.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { html } from "lit"
import { fixture, expect } from "@open-wc/testing"

import "../../../exports/define/input.js"

async function defaultFixture() {
return fixture(html` <leu-input> Name </leu-input> `)
}

describe("LeuInput", () => {
it("is a defined element", async () => {
const el = await customElements.get("leu-input")

await expect(el).not.to.be.undefined
})

it("passes the a11y audit", async () => {
const el = await defaultFixture()

await expect(el).shadowDom.to.be.accessible()
})
})
38 changes: 38 additions & 0 deletions src/components/radio/test/radio.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { html } from "lit"
import { fixture, expect } from "@open-wc/testing"

import "../../../exports/define/radio.js"
import "../../../exports/define/radio-group.js"

async function defaultFixture() {
return fixture(html`
<leu-radio-group>
<span slot="legend">Legende</span>
<leu-radio identifier="1" value="1" name="radio-button" disabled
>Kurz</leu-radio
>
<leu-radio identifier="2" value="2" name="radio-button"
>Etwas Länger</leu-radio
>
<leu-radio identifier="3" value="3" name="radio-button"
>Ein langes Label um sicher ein umbruch zu erzwingen</leu-radio
>
</leu-radio-group>
`)
}

describe("LeuRadio", () => {
it("is a defined element", async () => {
const elRadio = await customElements.get("leu-radio")
const elRadioGroup = await customElements.get("leu-radio-group")

await expect(elRadio).not.to.be.undefined
await expect(elRadioGroup).not.to.be.undefined
})

it("passes the a11y audit", async () => {
const el = await defaultFixture()

await expect(el).shadowDom.to.be.accessible()
})
})
29 changes: 29 additions & 0 deletions src/components/select/test/select.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { html } from "lit"
import { fixture, expect } from "@open-wc/testing"

import "../../../exports/define/select.js"

async function defaultFixture() {
return fixture(html`
<leu-select
options='[{"label":"Option 1", "value":"1"}, "Option 2", "Option 3", "Sehr lange Option um zu schauen was passiert, wenn es zu lang wird."]'
label="Label"
value=${null}
>
</leu-select>
`)
}

describe("LeuSelect", () => {
it("is a defined element", async () => {
const el = await customElements.get("leu-select")

await expect(el).not.to.be.undefined
})

it("passes the a11y audit", async () => {
const el = await defaultFixture()

await expect(el).shadowDom.to.be.accessible()
})
})
36 changes: 36 additions & 0 deletions src/components/table/test/table.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { html } from "lit"
import { fixture, expect } from "@open-wc/testing"

import "../../../exports/define/table.js"

const columns = [
{ name: "Id", value: (row) => row.id },
{ name: "Name", value: (row) => row.name },
{ name: "Menge", value: (row) => row.menge },
]

const data = [
{ id: 1, name: "Apfel", menge: 4 },
{ id: 2, name: "Birne", menge: 2 },
{ id: 3, name: "Banane", menge: 3 },
{ id: 4, name: "Orange", menge: 7 },
]

async function defaultFixture() {
return fixture(html`<leu-table .columns=${columns} .data=${data}>
</leu-table>`)
}

describe("LeuTable", () => {
it("is a defined element", async () => {
const el = await customElements.get("leu-table")

await expect(el).not.to.be.undefined
})

it("passes the a11y audit", async () => {
const el = await defaultFixture()

await expect(el).shadowDom.to.be.accessible()
})
})

0 comments on commit e24d6d0

Please sign in to comment.