Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: increase coverage #95

Merged
merged 20 commits into from
Jul 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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