11import { typeOf } from '@angular-package/type' ;
2- import { Testing , TestingToBeMatchers } from '@angular-package/testing' ;
2+ import { Testing , TestingToBeMatchers , TESTING_ARRAY_BIGINT } from '@angular-package/testing' ;
33import { Wrap } from '../lib/wrap.class' ;
44
55const testing = new Testing ( true , true ) ;
@@ -14,6 +14,9 @@ testing.describe(`Wrap`, () => {
1414 const replaceText = 'span' ;
1515 const text = `quote` ;
1616 const wrap = new Wrap ( opening , closing , text ) ;
17+ const wrapNull = new Wrap ( null as any , null as any ) ;
18+ const wrapUndefined = new Wrap ( undefined as any , undefined as any , undefined as any ) ;
19+ const wrapArrayBigInt = new Wrap ( TESTING_ARRAY_BIGINT as any , TESTING_ARRAY_BIGINT as any ) ;
1720
1821 testing
1922
@@ -22,26 +25,37 @@ testing.describe(`Wrap`, () => {
2225
2326 . it ( `Wrap.prototype.closing` , ( ) => {
2427 expect ( wrap . closing ) . toEqual ( closing ) ;
28+ expect ( wrapNull . closing ) . toEqual ( 'null' ) ;
29+ expect ( wrapUndefined . closing ) . toEqual ( 'undefined' ) ;
2530 toBe . stringIncludes ( wrap . closing , [ closing ] ) ;
31+ expect ( wrapArrayBigInt . closing ) . toEqual ( '9007199254740991,9007199254740991' ) ;
2632 } )
2733
2834 . it ( `Wrap.prototype.opening` , ( ) => {
2935 expect ( wrap . opening ) . toEqual ( opening ) ;
36+ expect ( wrapNull . opening ) . toEqual ( 'null' ) ;
37+ expect ( wrapUndefined . opening ) . toEqual ( 'undefined' ) ;
3038 toBe . stringIncludes ( wrap . valueOf ( ) , [ opening ] ) ;
39+ expect ( wrapArrayBigInt . opening ) . toEqual ( '9007199254740991,9007199254740991' ) ;
3140 } )
3241
3342 . it ( `Wrap.prototype.text` , ( ) => {
3443 expect ( wrap . text ) . toEqual ( text ) ;
44+ expect ( wrapNull . text ) . toEqual ( '' ) ;
45+ expect ( wrapUndefined . text ) . toEqual ( '' ) ;
3546 toBe . stringIncludes ( wrap . valueOf ( ) , [ text ] ) ;
3647 } )
3748
38- . it ( `Wrap.prototype.value ` , ( ) => {
49+ . it ( `Wrap.prototype.valueOf() ` , ( ) => {
3950 expect ( wrap . valueOf ( ) ) . toEqual ( `${ opening } ${ text } ${ closing } ` ) ;
51+ expect ( wrapNull . valueOf ( ) ) . toEqual ( 'nullnull' ) ;
52+ expect ( wrapUndefined . valueOf ( ) ) . toEqual ( 'undefinedundefined' ) ;
4053 toBe . stringIncludes ( wrap . valueOf ( ) , [ opening , text , closing ] ) ;
4154 } )
4255
4356 . it ( `[Symbol.toStringTag]` , ( ) => {
4457 expect ( typeOf ( wrap ) ) . toEqual ( 'wrap' ) ;
58+ expect ( Object . prototype . toString . call ( wrap ) ) . toEqual ( '[object Wrap]' ) ;
4559 } ) ;
4660 } )
4761
@@ -57,6 +71,21 @@ testing.describe(`Wrap`, () => {
5771 expect ( Wrap . isWrap ( wrap , opening , closing , undefined ) ) . toEqual ( true ) ;
5872 } )
5973
74+ . it ( `Wrap.hasClosing()` , ( ) => {
75+ expect ( Wrap . hasClosing ( `${ opening } ${ text } ${ closing } ` , closing ) ) . toBeTrue ( ) ;
76+ expect ( Wrap . hasClosing ( `${ opening } ${ text } ${ closing } ` , opening ) ) . toBeFalse ( ) ;
77+ } )
78+
79+ . it ( `Wrap.hasOpening()` , ( ) => {
80+ expect ( Wrap . hasOpening ( `${ opening } ${ text } ${ closing } ` , opening ) ) . toBeTrue ( ) ;
81+ expect ( Wrap . hasOpening ( `${ opening } ${ text } ${ closing } ` , closing ) ) . toBeFalse ( ) ;
82+ } ) ;
83+
84+ } )
85+
86+ . describe ( `methods` , ( ) => {
87+ testing
88+
6089 . it ( `Wrap.prototype.getClosing()` , ( ) => {
6190 expect ( wrap . getClosing ( ) ) . toEqual ( closing ) ;
6291 toBe . stringIncludes ( wrap . getClosing ( ) , [ closing ] ) ;
@@ -139,6 +168,8 @@ testing.describe(`Wrap`, () => {
139168 expect ( new Wrap ( '<' , '>' ) . isWrapped ( ) ) . toBeTrue ( ) ;
140169 expect ( new Wrap ( '<' , '>' ) . isWrapped ( '<' ) ) . toBeTrue ( ) ;
141170 expect ( new Wrap ( '<' , '>' ) . isWrapped ( undefined , '>' ) ) . toBeTrue ( ) ;
171+ expect ( new Wrap ( '<' , '>' ) . isWrapped ( '' , '>' ) ) . toBeFalse ( ) ;
172+ expect ( new Wrap ( '<' , '>' ) . isWrapped ( '<' , '' ) ) . toBeFalse ( ) ;
142173 } )
143174
144175 . it ( `Wrap.prototype.replaceClosing()` , ( ) => {
0 commit comments