@@ -532,7 +532,7 @@ test('mapDeep', () => {
532532 ] ) ;
533533} ) ;
534534
535- describe ( 'fuzzySearchTree' , ( ) => {
535+ describe ( 'fuzzySearchTree: keywords ' , ( ) => {
536536 test ( 'search by keyword' , ( ) => {
537537 // 定义树结构
538538 const tree = [
@@ -566,6 +566,7 @@ describe('fuzzySearchTree', () => {
566566 ]
567567 }
568568 ] ;
569+ const clone = cloneDeep ( tree ) ;
569570
570571 // 测试keyword 1
571572 const query = 'apr' ;
@@ -677,9 +678,10 @@ describe('fuzzySearchTree', () => {
677678 ]
678679 }
679680 ] ) ;
681+ expect ( tree ) . toEqual ( clone ) ;
680682 } ) ;
681683
682- test ( 'search by filter function, include not ignore case' , ( ) => {
684+ test ( 'fuzzySearchTree: search by filter function, include not ignore case' , ( ) => {
683685 const res1 = [ ] ;
684686 const res2 = [ ] ;
685687 // 定义树结构
@@ -697,7 +699,7 @@ describe('fuzzySearchTree', () => {
697699 {
698700 id : 3 ,
699701 name : 'Anpricot' ,
700- children : [ { id : 5 , name : 'butterfly' } ]
702+ children : [ { id : 35 , name : 'butterfly' } ]
701703 } ,
702704 {
703705 id : 4 ,
@@ -731,6 +733,7 @@ describe('fuzzySearchTree', () => {
731733 ]
732734 }
733735 ] ;
736+ const clone = cloneDeep ( tree ) ;
734737 const query = 'An' ;
735738 // keyword模式匹配,不忽略大小写
736739 const result1 = fuzzySearchTree (
@@ -821,5 +824,7 @@ describe('fuzzySearchTree', () => {
821824 // keyword匹配模式,且keyword为空串
822825 const result4 = fuzzySearchTree ( tree , { keyword : '' } ) ;
823826 expect ( result4 ) . toBe ( tree ) ;
827+
828+ expect ( tree ) . toEqual ( clone ) ;
824829 } ) ;
825830} ) ;
0 commit comments