Skip to content

Commit

Permalink
test: add pos tags to report
Browse files Browse the repository at this point in the history
  • Loading branch information
noomorph committed Jun 18, 2024
1 parent 6f3783f commit f5e5361
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
3 changes: 2 additions & 1 deletion 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, toHTML } = require('./dist/__utils__');
const { findLemmaById, findPosTags, toHTML } = require('./dist/__utils__');

const isId = (value) => Number.isFinite(parseInt(value, 10));

Expand Down Expand Up @@ -92,6 +92,7 @@ const allureConfig = {
tags.push('deletion');
}

tags.push(...findPosTags(testCase.title));
return tags;
},
},
Expand Down
2 changes: 1 addition & 1 deletion src/__utils__/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export * from './toHTML';
export * from './findLemmaById';
export * from './lemmata';
export * as fixtures from './fixtures';
13 changes: 13 additions & 0 deletions src/__utils__/findLemmaById.ts → src/__utils__/lemmata.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import fs from 'node:fs';
import path from 'node:path';
import { parsePos } from '../partOfSpeech';

const fixturesDir = path.join(__dirname, '../../src/__fixtures__');

Expand All @@ -9,6 +10,18 @@ export function findLemmaById(id: string): string {
return initFixtures().get(id)?.[2] ?? id;
}

export function findPosTags(id: string): string[] {
const pos = initFixtures().get(id)?.[1];
if (!pos) return [];

const { name, ...attributes } = parsePos(pos);
const trueAttributes = Object.entries(attributes)
.filter(([_, value]) => value)
.map(([key]) => key);

return [name, ...trueAttributes];
}

function initFixtures() {
if (!fixtures) {
const map = (fixtures = new Map());
Expand Down

0 comments on commit f5e5361

Please sign in to comment.