Skip to content

Commit

Permalink
test: add beforeAll instead of async describe (#44)
Browse files Browse the repository at this point in the history
Signed-off-by: Yokozuna59 <u.yokozuna@gmail.com>
  • Loading branch information
Yokozuna59 authored May 20, 2023
1 parent 89d0d1c commit 01aebbe
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 28 deletions.
44 changes: 26 additions & 18 deletions packages/mermaid-parser/tests/common/accessible.test.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,27 @@
import { createServicesForGrammar } from 'langium';
import { createServicesForGrammar, LangiumDocument } from 'langium';
import { parseHelper } from 'langium/lib/test';
import { describe, expect, it } from 'vitest';
import { beforeAll, describe, expect, it } from 'vitest';

import {
Mermaid,
MermaidGrammar,
MermiadTokenBuilder,
} from '../../src/language';

describe('when parsing accTitle', async () => {
const services = await createServicesForGrammar({
grammar: MermaidGrammar(),
module: {
parser: {
TokenBuilder: () => new MermiadTokenBuilder(),
describe('when parsing accTitle', () => {
let parser: (input: string) => Promise<LangiumDocument<Mermaid>>;

beforeAll(async () => {
const services = await createServicesForGrammar({
grammar: MermaidGrammar(),
module: {
parser: {
TokenBuilder: () => new MermiadTokenBuilder(),
},
},
},
});
parser = parseHelper<Mermaid>(services);
});
const parser = parseHelper<Mermaid>(services);

it.each([
// without whitespaces
Expand Down Expand Up @@ -98,16 +102,20 @@ describe('when parsing accTitle', async () => {
// });
});

describe('when parsing accDescr', async () => {
const services = await createServicesForGrammar({
grammar: MermaidGrammar(),
module: {
parser: {
TokenBuilder: () => new MermiadTokenBuilder(),
describe('when parsing accDescr', () => {
let parser: (input: string) => Promise<LangiumDocument<Mermaid>>;

beforeAll(async () => {
const services = await createServicesForGrammar({
grammar: MermaidGrammar(),
module: {
parser: {
TokenBuilder: () => new MermiadTokenBuilder(),
},
},
},
});
parser = parseHelper<Mermaid>(services);
});
const parser = parseHelper<Mermaid>(services);

// single line
it.each([
Expand Down
24 changes: 14 additions & 10 deletions packages/mermaid-parser/tests/pie/syntax.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { createServicesForGrammar } from 'langium';
import { createServicesForGrammar, LangiumDocument } from 'langium';
import { parseHelper } from 'langium/lib/test';
import { describe, expect, it } from 'vitest';
import { beforeAll, describe, expect, it } from 'vitest';

import {
Mermaid,
Expand All @@ -9,16 +9,20 @@ import {
PieChart,
} from '../../src/language';

describe('valid pie chart codes', async () => {
const services = await createServicesForGrammar({
grammar: MermaidGrammar(),
module: {
parser: {
TokenBuilder: () => new MermiadTokenBuilder(),
describe('valid pie chart codes', () => {
let parser: (input: string) => Promise<LangiumDocument<Mermaid>>;

beforeAll(async () => {
const services = await createServicesForGrammar({
grammar: MermaidGrammar(),
module: {
parser: {
TokenBuilder: () => new MermiadTokenBuilder(),
},
},
},
});
parser = parseHelper<Mermaid>(services);
});
const parser = parseHelper<Mermaid>(services);

// pie
it.each([
Expand Down

0 comments on commit 01aebbe

Please sign in to comment.