Skip to content

Commit

Permalink
fix(report): fix declaration a11y summary (#120)
Browse files Browse the repository at this point in the history
* fix(report): fix declaration a11y summary

* snaps
  • Loading branch information
Julien Bouquillon authored Jan 13, 2022
1 parent 0d18f02 commit 42fe4ba
Show file tree
Hide file tree
Showing 6 changed files with 2,262 additions and 2,274 deletions.
2 changes: 1 addition & 1 deletion report/src/__snapshots__/generateUrlReport.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Object {
"totalCount": 42,
},
"declaration-a11y": Object {
"declaration": "Accessibilité : partiellement conforme",
"mention": "Accessibilité : partiellement conforme",
},
"dependabot": Object {
"report": "dependabotalerts.json",
Expand Down
2 changes: 1 addition & 1 deletion report/src/generateUrlReport.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ describe("generateUrlReport", () => {
mockJson("stats.json", { report: "stats.json" });
mockJson("404.json", { broken: [1, 2, 3] });
mockJson("declaration-a11y.json", {
declaration: "Accessibilité : partiellement conforme",
mention: "Accessibilité : partiellement conforme",
});

expect(
Expand Down
6 changes: 3 additions & 3 deletions report/src/summary/declaration-a11y.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ const summary = (report) => {
"declaration-a11y": undefined,
};
}
const foundGradeIndex = report.declaration
? Object.values(grades).indexOf(report.declaration)
const foundGradeIndex = report.mention
? Object.values(grades).indexOf(report.mention)
: -1;

if (report.declaration === null) {
if (report.mention === null) {
// not detected
grade = "F";
} else if (foundGradeIndex > -1) {
Expand Down
15 changes: 8 additions & 7 deletions report/src/summary/declaration-a11y.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,32 @@ const summary = require("./declaration-a11y");

const tests = [
{
declaration: undefined,
mention: undefined,
expected: { "declaration-a11y": undefined },
},
{
declaration: null,
mention: null,
expected: { "declaration-a11y": "F" },
},
{
declaration: "Accessibilité : totalement conforme",
mention: "Accessibilité : totalement conforme",
expected: { "declaration-a11y": "A" },
},
{
declaration: "Accessibilité : partiellement conforme",
mention: "Accessibilité : partiellement conforme",
expected: { "declaration-a11y": "B" },
},
{
declaration: "Accessibilité : non conforme",
mention: "Accessibilité : non conforme",
expected: { "declaration-a11y": "C" },
},
];

describe("declaration-a11y", () => {
tests.forEach((t) => {
test(`${t.declaration} should return ${JSON.stringify(t.expected)}`, () => {
expect(summary({ declaration: t.declaration })).toEqual(t.expected);
test(`${t.mention} should return ${JSON.stringify(t.expected)}`, () => {
//@ts-expect-error
expect(summary({ mention: t.mention })).toEqual(t.expected);
});
});
});
1 change: 1 addition & 0 deletions report/src/summary/http.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const tests = [
describe("http", () => {
tests.forEach((t) => {
test(`${t.title} should return ${JSON.stringify(t.expected)}`, () => {
//@ts-expect-error
expect(summary(t.report)).toEqual(t.expected);
});
});
Expand Down
Loading

0 comments on commit 42fe4ba

Please sign in to comment.