ConceptPortal-public/rsconcept/frontend/src/models/rslangAPI.test.ts
2023-12-28 14:04:44 +03:00

30 lines
1.1 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { extractGlobals, splitTemplateDefinition } from './rslangAPI';
const globalsData = [
['', ''],
['X1', 'X1'],
['X11 X1 X11', 'X11 X1'],
['∀α∈S1 ∀β∈F1[α] Pr1,1(β)∩β=∅', 'S1 F1']
];
describe('Testing extract globals', () => {
it.each(globalsData)('Extract globals %p', (input: string, expected: string) => {
const result = extractGlobals(input);
expect([...result].join(' ')).toBe(expected);
});
});
const splitData = [
['', '||'],
['[α∈ℬ(R1)] α⊆red(σ)', 'α∈ℬ(R1)||α⊆red(σ)'],
['[α∈ℬ(R1)] α⊆red(σ) ', 'α∈ℬ(R1)||α⊆red(σ)'],
[' [α∈ℬ(R1)] α⊆red(σ)', 'α∈ℬ(R1)||α⊆red(σ)'],
['[α∈ℬ(R1)]α⊆red(σ)', 'α∈ℬ(R1)||α⊆red(σ)'],
['[α∈ℬ(R1), σ∈ℬℬ(R1)] α⊆red(σ)', 'α∈ℬ(R1), σ∈ℬℬ(R1)||α⊆red(σ)']
];
describe('Testing split template', () => {
it.each(splitData)('Split %p', (input: string, expected: string) => {
const result = splitTemplateDefinition(input);
expect(`${result.head}||${result.body}`).toBe(expected);
});
});