Skip to content

Commit fbe020f

Browse files
test(wink-nlp-specs): add test cases for mark in learnCustomEntities
1 parent f55bade commit fbe020f

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

test/wink-nlp-specs.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -576,6 +576,22 @@ describe( 'Learn Custom Entities', function () {
576576
expect( nlp.learnCustomEntities.bind( null, [ { name: 'ok', patterns: [ '[a#]' ] } ] ) ).to.throw( 'wink-nlp: incorrect token "a#" encountered in examples of learnCustomEntities() API.' );
577577
} );
578578

579+
it( 'should throw error if mark is empty', function () {
580+
expect( nlp.learnCustomEntities.bind( null, [ { name: 'ok', patterns: [ 'a b' ], mark: [] } ] ) ).to.throw( 'wink-nlp: mark should be an array containing start & end indexes, instead found:' );
581+
} );
582+
583+
it( 'should throw error if mark contains real numbers', function () {
584+
expect( nlp.learnCustomEntities.bind( null, [ { name: 'ok', patterns: [ 'a b' ], mark: [ 1, 1.2 ] } ] ) ).to.throw( 'wink-nlp: mark should be an array containing start & end indexes, instead found:' );
585+
} );
586+
587+
it( 'should throw error if within mark start index > end index', function () {
588+
expect( nlp.learnCustomEntities.bind( null, [ { name: 'ok', patterns: [ 'a b' ], mark: [ 2, 1 ] } ] ) ).to.throw( 'wink-nlp: mark should be an array containing start & end indexes, instead found:' );
589+
} );
590+
591+
it( 'should throw error if mark contains non integer', function () {
592+
expect( nlp.learnCustomEntities.bind( null, [ { name: 'ok', patterns: [ 'a b' ], mark: [ 'a' ] } ] ) ).to.throw( 'wink-nlp: mark should be an array containing start & end indexes, instead found:' );
593+
} );
594+
579595
it( 'correct examples should return the count of examples learned', function () {
580596
expect( nlp.learnCustomEntities( [ { name: 'ok', patterns: [ 'a b' ] } ] ) ).to.equal( 1 );
581597
} );

0 commit comments

Comments
 (0)