Skip to content

Commit

Permalink
test(ner): add for deserialize JSON
Browse files Browse the repository at this point in the history
  • Loading branch information
AndersDJohnson authored May 19, 2023
1 parent 1e05fdf commit 2231050
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions packages/ner/test/ner.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -485,4 +485,29 @@ describe('NER', () => {
]);
});
});
describe('To & from JSON', () => {
test('It deserializes regular expressions', () => {
const instance = new Ner({ container });
instance.addBetweenCondition('en', 'test', 'from', 'to');
const json = JSON.stringify(instance.toJSON());
const instance2 = new Ner({ container });
instance2.fromJSON(JSON.parse(json));
const actual = instance2.getRules('en');
expect(actual).toEqual([
{
name: 'test',
rules: [
{
type: 'between',
leftWords: ['from'],
rightWords: ['to'],
regex: /(?<= from )(.*)(?= to )/gi,
options: {},
},
],
type: 'trim',
},
]);
});
});
});

0 comments on commit 2231050

Please sign in to comment.