mirror of
https://activitypub.software/TransFem-org/sfm-js
synced 2024-11-23 22:45:12 +00:00
fix our tests
This commit is contained in:
parent
0a7292ad53
commit
b33e9ee8dc
1 changed files with 10 additions and 5 deletions
15
test/core.ts
15
test/core.ts
|
@ -1,28 +1,33 @@
|
|||
import assert from 'assert';
|
||||
import * as P from '../src/internal/core';
|
||||
|
||||
const state = {
|
||||
nestLimit: 3,
|
||||
depth: 0,
|
||||
};
|
||||
|
||||
describe('core', () => {
|
||||
describe('difference', () => {
|
||||
test('basic', () => {
|
||||
const parser = P.difference(P.regexp(/\p{Letter}/u), P.str('x'));
|
||||
|
||||
let result = parser.handler('x',0,{}) as P.Success<any>;
|
||||
let result = parser.handler('x',0,state) as P.Success<any>;
|
||||
assert.deepStrictEqual(result,P.failure());
|
||||
|
||||
result = parser.handler('a',0,{}) as P.Success<any>;
|
||||
result = parser.handler('a',0,state) as P.Success<any>;
|
||||
assert.deepStrictEqual(result,P.success(1,'a'));
|
||||
});
|
||||
|
||||
test('horizontal whitespace', () => {
|
||||
const parser = P.difference(P.regexp(/\s/u), P.newline);
|
||||
|
||||
let result = parser.handler('\n',0,{}) as P.Success<any>;
|
||||
let result = parser.handler('\n',0,state) as P.Success<any>;
|
||||
assert.deepStrictEqual(result,P.failure());
|
||||
|
||||
result = parser.handler(' ',0,{}) as P.Success<any>;
|
||||
result = parser.handler(' ',0,state) as P.Success<any>;
|
||||
assert.deepStrictEqual(result,P.success(1,' '));
|
||||
|
||||
result = parser.handler('\t',0,{}) as P.Success<any>;
|
||||
result = parser.handler('\t',0,state) as P.Success<any>;
|
||||
assert.deepStrictEqual(result,P.success(1,'\t'));
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in a new issue