Merge branch 'next' into pr/Yokozuna59/4751

* next: (70 commits)
  chore: Add comment for `yy`.
  chore: Increase heap size when building
  chore: increase `test-util.ts` converage by returning `undefined`
  chore: add `vitest` imports to `test-util.ts`
  chore: run `pnpm lint:fix`
  create `noErrorsOrAlternatives` parser helper function
  chore: export `InfoModule` from `infoModule.ts`
  docs: Fix link
  Update docs
  fix(pie): align slices and legend orders
  Mermaid version v10.4.0
  unique batches every time, if not repeated tests end up in the same batch
  Added missed .md
  Increase JS heap
  More tests for redirects + prettier
  Fixed redirects inside vitepress, extended tests
  chore: Explain redirect.ts clearly
  docs: Fix npmjs link
  chore: Update editor.bash to build latest version
  chore: Build after clone
  ...
This commit is contained in:
Sidharth Vinod
2023-08-28 14:13:20 +05:30
128 changed files with 2240 additions and 1739 deletions

View File

@@ -3,10 +3,11 @@ import type { LangiumParser, ParseResult } from 'langium';
import type { InfoServices } from '../src/language/index.js';
import { Info, createInfoServices } from '../src/language/index.js';
import { noErrorsOrAlternatives } from './test-util.js';
const services: InfoServices = createInfoServices().Info;
const parser: LangiumParser = services.parser.LangiumParser;
export function createInfoTestServices(): {
function createInfoTestServices(): {
services: InfoServices;
parse: (input: string) => ParseResult<Info>;
} {
@@ -30,11 +31,10 @@ describe('info', () => {
info
`,
])('should handle empty info', (context: string) => {
const { parserErrors, lexerErrors, value } = parse(context);
expect(parserErrors).toHaveLength(0);
expect(lexerErrors).toHaveLength(0);
const result = parse(context);
noErrorsOrAlternatives(result);
expect(value.$type).toBe(Info);
expect(result.value.$type).toBe(Info);
});
it.each([
@@ -49,10 +49,9 @@ describe('info', () => {
showInfo
`,
])('should handle showInfo', (context: string) => {
const { parserErrors, lexerErrors, value } = parse(context);
expect(parserErrors).toHaveLength(0);
expect(lexerErrors).toHaveLength(0);
const result = parse(context);
noErrorsOrAlternatives(result);
expect(value.$type).toBe(Info);
expect(result.value.$type).toBe(Info);
});
});

View File

@@ -0,0 +1,18 @@
import { expect, vi } from 'vitest';
import type { ParseResult } from 'langium';
const consoleMock = vi.spyOn(console, 'log').mockImplementation(() => undefined);
/**
* A helper test function that validate that the result doesn't have errors
* or any ambiguous alternatives from chevrotain.
*
* @param result - the result `parse` function.
*/
export function noErrorsOrAlternatives(result: ParseResult) {
expect(result.lexerErrors).toHaveLength(0);
expect(result.parserErrors).toHaveLength(0);
expect(consoleMock).not.toHaveBeenCalled();
consoleMock.mockReset();
}