Skip to content

Commit

Permalink
update sankey parser tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Yokozuna59 committed Feb 12, 2024
1 parent aa9e875 commit 15c8bf8
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 21 deletions.
22 changes: 3 additions & 19 deletions packages/parser/tests/sankey.test.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,9 @@
import { describe, expect, it } from 'vitest';
import type { LangiumParser, ParseResult } from 'langium';

import type { SankeyServices } from '../src/language/index.js';
import { Sankey, createSankeyServices } from '../src/language/index.js';
import { expectNoErrorsOrAlternatives } from './test-util.js';

const services: SankeyServices = createSankeyServices().Sankey;
const parser: LangiumParser = services.parser.LangiumParser;
export function createSankeyTestServices(): {
services: SankeyServices;
parse: (input: string) => ParseResult<Sankey>;
} {
const parse = (input: string) => {
return parser.parse<Sankey>(input);
};
return { services, parse };
}

describe('sankey', () => {
const { parse } = createSankeyTestServices();
import { Sankey } from '../src/language/index.js';
import { expectNoErrorsOrAlternatives, sankeyParse as parse } from './test-util.js';

describe('sankey', () => {
it('should handle simple sankey', () => {
const context = `sankey-beta
sourceNode, targetNode, 10`;
Expand Down
25 changes: 23 additions & 2 deletions packages/parser/tests/test-util.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,18 @@
import type { LangiumParser, ParseResult } from 'langium';
import { expect, vi } from 'vitest';
import type { Info, InfoServices, Pie, PieServices } from '../src/language/index.js';
import { createInfoServices, createPieServices } from '../src/language/index.js';
import type {
Info,
InfoServices,
Pie,
PieServices,
Sankey,
SankeyServices,
} from '../src/language/index.js';
import {
createInfoServices,
createPieServices,
createSankeyServices,
} from '../src/language/index.js';

const consoleMock = vi.spyOn(console, 'log').mockImplementation(() => undefined);

Expand Down Expand Up @@ -40,3 +51,13 @@ export function createPieTestServices() {
return { services: pieServices, parse };
}
export const pieParse = createPieTestServices().parse;

const sankeyServices: SankeyServices = createSankeyServices().Sankey;
const sankeyParser: LangiumParser = sankeyServices.parser.LangiumParser;
export function createSankeyTestServices() {
const parse = (input: string) => {
return sankeyParser.parse<Sankey>(input);
};
return { services: sankeyServices, parse };
}
export const sankeyParse = createSankeyTestServices().parse;

0 comments on commit 15c8bf8

Please sign in to comment.