@@ -30,52 +30,52 @@ describe('findInvisibleCharacters', () => {
3030 } ) ;
3131
3232 it . each ( [
33- [ ' ' , 'nonBreakingSpace' ] ,
34- [ ' ' , 'nonBreakingSpace' ] ,
35- [ ' ' , 'nonBreakingSpace' ] ,
36- [ ' ' , 'zeroWidth' ] ,
37- [ ' ' , 'zeroWidth' ] ,
38- [ ' ' , 'zeroWidth' ] ,
33+ [ '\u00A0 ' , 'nonBreakingSpace' ] ,
34+ [ '\u202F ' , 'nonBreakingSpace' ] ,
35+ [ '\u2007 ' , 'nonBreakingSpace' ] ,
36+ [ '\u200B ' , 'zeroWidth' ] ,
37+ [ '\uFEFF ' , 'zeroWidth' ] ,
38+ [ '\u00AD ' , 'zeroWidth' ] ,
3939 ] ) ( 'finds %j and reports kind %s' , ( value , kind ) => {
4040 expect ( findInvisibleCharacters ( `a${ value } b` ) ) . toEqual ( [
4141 { index : 1 , char : { value, kind } } ,
4242 ] ) ;
4343 } ) ;
4444
4545 it ( 'finds a character at the first index' , ( ) => {
46- expect ( findInvisibleCharacters ( ' abc ' ) ) . toEqual ( [
47- { index : 0 , char : { value : ' ' , kind : 'nonBreakingSpace' } } ,
46+ expect ( findInvisibleCharacters ( '\u00A0abc ' ) ) . toEqual ( [
47+ { index : 0 , char : { value : '\u00A0 ' , kind : 'nonBreakingSpace' } } ,
4848 ] ) ;
4949 } ) ;
5050
5151 it ( 'finds a character at the last index' , ( ) => {
52- expect ( findInvisibleCharacters ( 'abc ' ) ) . toEqual ( [
53- { index : 3 , char : { value : ' ' , kind : 'nonBreakingSpace' } } ,
52+ expect ( findInvisibleCharacters ( 'abc\u00A0 ' ) ) . toEqual ( [
53+ { index : 3 , char : { value : '\u00A0 ' , kind : 'nonBreakingSpace' } } ,
5454 ] ) ;
5555 } ) ;
5656
5757 it ( 'finds multiple characters in ascending order' , ( ) => {
58- expect ( findInvisibleCharacters ( 'a bc ' ) ) . toEqual ( [
59- { index : 1 , char : { value : ' ' , kind : 'nonBreakingSpace' } } ,
60- { index : 3 , char : { value : ' ' , kind : 'zeroWidth' } } ,
58+ expect ( findInvisibleCharacters ( 'a\u00A0b\u200Bc ' ) ) . toEqual ( [
59+ { index : 1 , char : { value : '\u00A0 ' , kind : 'nonBreakingSpace' } } ,
60+ { index : 3 , char : { value : '\u200B ' , kind : 'zeroWidth' } } ,
6161 ] ) ;
6262 } ) ;
6363
6464 it ( 'finds adjacent characters' , ( ) => {
65- expect ( findInvisibleCharacters ( ' ' ) ) . toEqual ( [
66- { index : 0 , char : { value : ' ' , kind : 'nonBreakingSpace' } } ,
67- { index : 1 , char : { value : ' ' , kind : 'nonBreakingSpace' } } ,
65+ expect ( findInvisibleCharacters ( '\u00A0\u00A0 ' ) ) . toEqual ( [
66+ { index : 0 , char : { value : '\u00A0 ' , kind : 'nonBreakingSpace' } } ,
67+ { index : 1 , char : { value : '\u00A0 ' , kind : 'nonBreakingSpace' } } ,
6868 ] ) ;
6969 } ) ;
7070
7171 it ( 'reports code-unit offsets in text containing surrogate pairs' , ( ) => {
72- expect ( findInvisibleCharacters ( '\u{1f600} ' ) ) . toEqual ( [
73- { index : 2 , char : { value : ' ' , kind : 'nonBreakingSpace' } } ,
72+ expect ( findInvisibleCharacters ( '\u{1f600}\u00A0 ' ) ) . toEqual ( [
73+ { index : 2 , char : { value : '\u00A0 ' , kind : 'nonBreakingSpace' } } ,
7474 ] ) ;
7575 } ) ;
7676
7777 it ( 'is stable across repeated calls' , ( ) => {
78- const text = 'a b ' ;
78+ const text = 'a\u00A0b ' ;
7979 expect ( findInvisibleCharacters ( text ) ) . toEqual (
8080 findInvisibleCharacters ( text )
8181 ) ;
0 commit comments