diff --git a/jest.config.js b/jest.config.js index df595f0..abd384c 100644 --- a/jest.config.js +++ b/jest.config.js @@ -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)); @@ -92,6 +92,7 @@ const allureConfig = { tags.push('deletion'); } + tags.push(...findPosTags(testCase.title)); return tags; }, }, diff --git a/src/__utils__/index.ts b/src/__utils__/index.ts index 41b59a4..b938170 100644 --- a/src/__utils__/index.ts +++ b/src/__utils__/index.ts @@ -1,3 +1,3 @@ export * from './toHTML'; -export * from './findLemmaById'; +export * from './lemmata'; export * as fixtures from './fixtures'; diff --git a/src/__utils__/findLemmaById.ts b/src/__utils__/lemmata.ts similarity index 64% rename from src/__utils__/findLemmaById.ts rename to src/__utils__/lemmata.ts index 44d153f..b4f9bf8 100644 --- a/src/__utils__/findLemmaById.ts +++ b/src/__utils__/lemmata.ts @@ -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__'); @@ -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());