mirror of
https://activitypub.software/TransFem-org/sfm-js
synced 2024-11-21 13:45:10 +00:00
2c7e152644
* lint: fix lint warning that is easy to fix * lint: typesafe signature of seqOrText * lint: typesafe createLanguage and language * lint: typesafe seq * lint: typesafe Parser.option * fix: node can be string * lint: typesafe alt * fix: invalid url in link element will cause error * chore: get rid of any * fix: unnecessary import * lint: kill any but still with loose type checking * Revert "lint: kill any but still with loose type checking" This reverts commit 8c7462f4a745800499a63ecf0632df3647b3e22c. * lint: kill any again * test: write type test * ci: upgrade node version for lint
30 lines
1 KiB
TypeScript
30 lines
1 KiB
TypeScript
/**
|
|
* Unit testing TypeScript types.
|
|
* with https://github.com/SamVerschueren/tsd
|
|
*/
|
|
|
|
import { expectType } from 'tsd';
|
|
import { NodeType, MfmUrl } from '../src';
|
|
import * as P from '../src/internal/core';
|
|
|
|
describe('#NodeType', () => {
|
|
test('returns node that has sprcified type', () => {
|
|
const x = null as unknown as NodeType<'url'>;
|
|
expectType<MfmUrl>(x);
|
|
});
|
|
});
|
|
|
|
describe('parser internals', () => {
|
|
test('seq', () => {
|
|
const first = null as unknown as P.Parser<'first'>;
|
|
const second = null as unknown as P.Parser<'second'>;
|
|
const third = null as unknown as P.Parser<'third' | 'third-second'>;
|
|
expectType<P.Parser<['first', 'second', 'third' | 'third-second']>>(P.seq(first, second, third));
|
|
});
|
|
test('alt', () => {
|
|
const first = null as unknown as P.Parser<'first'>;
|
|
const second = null as unknown as P.Parser<'second'>;
|
|
const third = null as unknown as P.Parser<'third' | 'third-second'>;
|
|
expectType<P.Parser<'first' | 'second' | 'third' | 'third-second'>>(P.alt([first, second, third]));
|
|
});
|
|
});
|