Skip to content

Commit

Permalink
test: increase coverage (#95)
Browse files Browse the repository at this point in the history
  • Loading branch information
greatislander authored Jul 12, 2024
1 parent 507fcf4 commit 096f6e5
Show file tree
Hide file tree
Showing 26 changed files with 888 additions and 320 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
with:
path: node_modules
key: ${{ runner.OS }}-build-${{ hashFiles('**/package-lock.json') }}
- name: Install dependencies and lint files
- name: Install dependencies, lint files and run tests
run: |
npm ci
npm run lint
Expand Down
1 change: 1 addition & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
npx --no -- commitlint --config commitlint.config.js --edit "$1"
1 change: 1 addition & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
npx --no lint-staged
38 changes: 34 additions & 4 deletions eleventy.config.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,46 @@
import { RenderPlugin } from "@11ty/eleventy";
import fetch from "@11ty/eleventy-fetch";
import syntaxHighlightPlugin from "@11ty/eleventy-plugin-syntaxhighlight";
// Import {$} from 'execa';
import newIssueUrl from "./src/_utils/new-issue-url.js";
import scSupport from "./src/_utils/sc-support.js";
import scTable from "./src/_utils/sc-table.js";

export default function eleventy(eleventyConfig) {
eleventyConfig.addNunjucksAsyncShortcode("scTable", scTable);
eleventyConfig.addNunjucksAsyncShortcode("scSupport", scSupport);
eleventyConfig.addShortcode("newIssueUrl", newIssueUrl);
eleventyConfig.addLayoutAlias("report", "report.njk");

eleventyConfig.addGlobalData("successCriteria", async () => {
const url = "https://raw.githubusercontent.com/w3c/wcag/main/guidelines/wcag.json";

try {
const json = await fetch(url, {
duration: "1d",
type: "json"
});

const results = {};

for (const principle of json.principles) {
for (const guideline of principle.guidelines) {
for (const sc of guideline.successcriteria) {
results[sc.num] = {
number: sc.num,
principle: principle.handle,
guideline: guideline.handle,
name: sc.handle,
level: sc.level,
versions: sc.versions,
id: sc.id.replace("WCAG2:", "")
};
}
}
}

return results;
} catch (error) {
console.error(`Fetch failed in successcriteria.js. ${error}`);
}
});

eleventyConfig.addPlugin(RenderPlugin);
eleventyConfig.addPlugin(syntaxHighlightPlugin);

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"lint:scripts": "biome check .",
"lint:markdown": "markdownlint-cli2 \"**/*.md\"",
"start": "npm-run-all -l clean dev",
"test": "c8 --all --src src -r clover -r text ava",
"test": "c8 --all --src src/_utils -r clover -r text ava",
"prepare": "husky"
},
"repository": {
Expand Down
Loading

0 comments on commit 096f6e5

Please sign in to comment.