-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- fix bug where id not added to heading (regression from 5c3728d) - add heading link to topmost h1 afterall - change `innerText` to `textContent` for support in jest (jsdom) - add section of routes for dev-only test routes - make testbed page for testing out and experimenting with component look and feel - make test for app heading component to see that auto level and link work
- Loading branch information
1 parent
8d785a2
commit f3a9767
Showing
7 changed files
with
122 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<!-- | ||
dev page for experimenting with design and behavior of components. also a | ||
place for seeing all variations at once to check for coherence. not included | ||
in production build of site. | ||
--> | ||
<template> | ||
<!-- status component --> | ||
<AppSection> | ||
<AppGallery> | ||
<AppStatus code="loading" text="Loading some results" /> | ||
<AppStatus code="success" text="Action was a success" /> | ||
<AppStatus code="warning" text="Be careful" /> | ||
<AppStatus code="error" text="There was an error" /> | ||
<AppStatus code="paused" text="Action is paused" /> | ||
<AppStatus code="unknown" text="Unexpected result" /> | ||
</AppGallery> | ||
</AppSection> | ||
<AppSection> | ||
<AppGallery> | ||
<AppStatus code="loading" design="big" text="Loading some results" /> | ||
<AppStatus code="success" design="big" text="Action was a success" /> | ||
<AppStatus code="warning" design="big" text="Be careful" /> | ||
<AppStatus code="error" design="big" text="There was an error" /> | ||
<AppStatus code="paused" design="big" text="Action is paused" /> | ||
<AppStatus code="unknown" design="big" text="Unexpected result" /> | ||
</AppGallery> | ||
</AppSection> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { sleep } from "./../../src/util/debug"; | ||
import { flushPromises, mount } from "@vue/test-utils"; | ||
import AppHeadings from "./AppHeadings.vue"; | ||
import { mountOptions } from "../setup"; | ||
|
||
const tags = "h1, h2, h3, h4"; | ||
|
||
test("Chooses heading levels correctly", async () => { | ||
// mount hoc | ||
const wrapper = mount(AppHeadings, mountOptions); | ||
|
||
// wait for everything to render | ||
await flushPromises(); | ||
|
||
// find all heading components | ||
const headings = wrapper.findAll(tags); | ||
|
||
// go through each | ||
for (const heading of headings) { | ||
// compare expected tag to actual rendered tag | ||
const received = heading.element.tagName.toLowerCase(); | ||
const expected = heading.attributes("data-tag")?.toLowerCase(); | ||
expect(received).toBe(expected); | ||
} | ||
}); | ||
|
||
test("Creates heading links correctly", async () => { | ||
// mount hoc | ||
const wrapper = mount(AppHeadings, mountOptions); | ||
|
||
// wait for everything to render | ||
await flushPromises(); | ||
await sleep(); | ||
|
||
// find all heading components | ||
const headings = wrapper.findAll(tags); | ||
|
||
// go through each | ||
for (const heading of headings) { | ||
// compare expected link to actual rendered link | ||
const received = heading.attributes("id"); | ||
const expected = heading.attributes("data-link"); | ||
expect(received).toBe(expected); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<template> | ||
<!-- | ||
higher-order component (hoc) to test heading auto-levels/links. use data | ||
attributes to indicate expected. | ||
--> | ||
<main> | ||
<AppSection> | ||
<AppHeading data-tag="h1" data-link="abc-def-gih">ABC-def_gih</AppHeading> | ||
</AppSection> | ||
<AppSection> | ||
<AppHeading data-tag="h2" data-link="123-alphabet-street"> | ||
123 Alphabet Street | ||
</AppHeading> | ||
<AppHeading data-tag="h3" data-link="aeo">áéó</AppHeading> | ||
</AppSection> | ||
</main> | ||
</template> |