Skip to content

Commit

Permalink
build: add noun and adjective table formatting (#30)
Browse files Browse the repository at this point in the history
  • Loading branch information
noomorph authored Feb 29, 2024
1 parent 933ba89 commit 2fbb205
Show file tree
Hide file tree
Showing 18 changed files with 1,199 additions and 93 deletions.
55 changes: 28 additions & 27 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// eslint-disable-next-line @typescript-eslint/no-var-requires
const { findLemmaById, toMarkdown } = require('./dist/__utils__');
const { findLemmaById, toHTML } = require('./dist/__utils__');

/** @type {import('jest-allure2-reporter').ReporterConfig} */
const allureConfig = {
Expand Down Expand Up @@ -34,33 +34,34 @@ const allureConfig = {

return value;
},
description: ({ testCase, value = '' }) => {
return testCase.status === 'failed'
? toMarkdown(testCase) + value
: value;
description: () => void 0,
descriptionHtml: ({ testCase, value = '' }) => {
const content =
testCase.status === 'failed' ? toHTML(testCase) + value : value;

return `\
<style>
figcaption { margin: 1em 0; font-style: italic; }
figure > table { margin-bottom: 0.75em }
figure th { background-color: #e4edfe }
figure th, figure td {
border: 1px solid #777;
padding: 0.5ch;
}
figure td > del {
background-color: #ffe7e6;
color: #9e0500;
display: block;
}
figure td > ins {
font-style: normal;
background-color: #eef9eb;
color: #125400;
display: block;
}
</style>
${content}`;
},
descriptionHtml: ({ value = '' }) => `\
<style>
h3 ~ table { margin-bottom: 1.25em }
h3 ~ table > thead { background-color: #e4edfe }
h3 ~ table th,
h3 ~ table td {
border: 1px solid #777;
padding: 0.5ch;
}
h3 ~ table del {
background-color: #ffe7e6;
color: #9e0500;
display: block;
}
h3 ~ table del + em {
font-style: normal;
background-color: #eef9eb;
color: #125400;
display: block;
}
</style>
${value}`,
},
testFile: {
hidden: () => false,
Expand Down
241 changes: 241 additions & 0 deletions src/__utils__/html/__snapshots__/adjective.test.ts.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,241 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`renderers HTML noun declension render 1`] = `
"<figure>
<figcaption>Adjective declension</figcaption>
<table>
<thead>
<tr>
<th></th>
<th colspan="3">singular</th>
</tr>
<tr>
<th>case</th>
<th>masculine</th>
<th>neuter</th>
<th>feminine</th>
</tr>
</thead>
<tbody>
<tr>
<th>Nom.</th>
<td>najdobry-koli</td>
<td>najdobro-koli</td>
<td>najdobra-koli</td>
</tr>
<tr>
<th>Acc.</th>
<td>najdobrogo-koli / najdobry-koli</td>
<td>najdobro-koli</td>
<td>najdobrų-koli</td>
</tr>
<tr>
<th>Gen.</th>
<td colspan="2">najdobrogo-koli</td>
<td>najdobroj-koli</td>
</tr>
<tr>
<th>Loc.</th>
<td colspan="2">najdobrom-koli</td>
<td>najdobroj-koli</td>
</tr>
<tr>
<th>Dat.</th>
<td colspan="2">najdobromu-koli</td>
<td>najdobroj-koli</td>
</tr>
<tr>
<th>Ins.</th>
<td colspan="2">najdobrym-koli</td>
<td>najdobrojų-koli</td>
</tr>
</tbody>
</table>
<table>
<tbody>
<tr>
<th></th>
<th colspan="2">plural</th>
</tr>
<tr>
<th>case</th>
<th>masculine</th>
<th>feminine/neuter</th>
</tr>
<tr>
<th>Nom.</th>
<td>najdobri-koli / najdobre-koli</td>
<td>najdobre-koli</td>
</tr>
<tr>
<th>Acc.</th>
<td>najdobryh-koli / najdobre-koli</td>
<td>najdobre-koli</td>
</tr>
<tr>
<th>Gen.</th>
<td colspan="2">najdobryh-koli</td>
</tr>
<tr>
<th>Loc.</th>
<td colspan="2">najdobryh-koli</td>
</tr>
<tr>
<th>Dat.</th>
<td colspan="2">najdobrym-koli</td>
</tr>
<tr>
<th>Ins.</th>
<td colspan="2">najdobrymi-koli</td>
</tr>
</tbody>
</table>
<table>
<tbody>
<tr>
<th>Degrees of comparison</th>
<th>adjective</th>
<th>adverb</th>
</tr>
<tr>
<th>positive</th>
<td>—</td>
<td>—</td>
</tr>
<tr>
<th>comparative</th>
<td>—</td>
<td>—</td>
</tr>
<tr>
<th>superlative</th>
<td>najdobry-koli</td>
<td>najdobry-koli</td>
</tr>
</tbody>
</table>
</figure>
"
`;

exports[`renderers HTML noun declension renderDiff 1`] = `
"<figure>
<figcaption>Adjective declension</figcaption>
<table>
<thead>
<tr>
<th></th>
<th colspan="3">singular</th>
</tr>
<tr>
<th>case</th>
<th>masculine</th>
<th>neuter</th>
<th>feminine</th>
</tr>
</thead>
<tbody>
<tr>
<th>Nom.</th>
<td><del>svěži</del> <ins>črstvy</ins></td>
<td><del>svěže</del> <ins>črstvo</ins></td>
<td><del>svěža</del> <ins>črstva</ins></td>
</tr>
<tr>
<th>Acc.</th>
<td><del>svěžego / svěži</del> <ins>črstvogo / črstvy</ins></td>
<td><del>svěže</del> <ins>črstvo</ins></td>
<td><del>svěžų</del> <ins>črstvų</ins></td>
</tr>
<tr>
<th>Gen.</th>
<td colspan="2"><del>svěžego</del> <ins>črstvogo</ins></td>
<td><del>svěžej</del> <ins>črstvoj</ins></td>
</tr>
<tr>
<th>Loc.</th>
<td colspan="2"><del>svěžem</del> <ins>črstvom</ins></td>
<td><del>svěžej</del> <ins>črstvoj</ins></td>
</tr>
<tr>
<th>Dat.</th>
<td colspan="2"><del>svěžemu</del> <ins>črstvomu</ins></td>
<td><del>svěžej</del> <ins>črstvoj</ins></td>
</tr>
<tr>
<th>Ins.</th>
<td colspan="2"><del>svěžim</del> <ins>črstvym</ins></td>
<td><del>svěžejų</del> <ins>črstvojų</ins></td>
</tr>
</tbody>
</table>
<table>
<tbody>
<tr>
<th></th>
<th colspan="2">plural</th>
</tr>
<tr>
<th>case</th>
<th>masculine</th>
<th>feminine/neuter</th>
</tr>
<tr>
<th>Nom.</th>
<td><del>svěži / svěže</del> <ins>črstvi / črstve</ins></td>
<td><del>svěže</del> <ins>črstve</ins></td>
</tr>
<tr>
<th>Acc.</th>
<td><del>svěžih / svěže</del> <ins>črstvyh / črstve</ins></td>
<td><del>svěže</del> <ins>črstve</ins></td>
</tr>
<tr>
<th>Gen.</th>
<td colspan="2"><del>svěžih</del> <ins>črstvyh</ins></td>
</tr>
<tr>
<th>Loc.</th>
<td colspan="2"><del>svěžih</del> <ins>črstvyh</ins></td>
</tr>
<tr>
<th>Dat.</th>
<td colspan="2"><del>svěžim</del> <ins>črstvym</ins></td>
</tr>
<tr>
<th>Ins.</th>
<td colspan="2"><del>svěžimi</del> <ins>črstvymi</ins></td>
</tr>
</tbody>
</table>
<table>
<tbody>
<tr>
<th>Degrees of comparison</th>
<th>adjective</th>
<th>adverb</th>
</tr>
<tr>
<th>positive</th>
<td><del>svěži</del> <ins>črstvy</ins></td>
<td><del>svěže</del> <ins>črstvo</ins></td>
</tr>
<tr>
<th>comparative</th>
<td><del>svěžejši</del> <ins>črstvějši</ins></td>
<td><del>svěžeje</del> <ins>črstvěje</ins></td>
</tr>
<tr>
<th>superlative</th>
<td><del>najsvěžejši</del> <ins>najčrstvějši</ins></td>
<td><del>najsvěžeje</del> <ins>najčrstvěje</ins></td>
</tr>
</tbody>
</table>
</figure>
"
`;
Loading

0 comments on commit 2fbb205

Please sign in to comment.