import 'mocha' ; import { expect } from 'chai' ; import { ILiquorTreeExistingNode } from 'liquor-tree' ; import { NodeType , INode } from '@/presentation/components/Scripts/View/ScriptsTree/SelectableTree/Node/INode' ; import { NodePredicateFilter } from '@/presentation/components/Scripts/View/ScriptsTree/SelectableTree/LiquorTree/NodeWrapper/NodePredicateFilter' ; describe ( 'NodePredicateFilter' , ( ) => { it ( 'calls predicate with expected node' , ( ) => { const object = { id : 'script' , data : { text : 'script-text' , type : NodeType . Script , documentationUrls : [ ] , isReversible : false , } , states : undefined , children : [ ] , } ; const expected = { id : 'script' , text : 'script-text' , isReversible : false , documentationUrls : [ ] , children : [ ] , type : NodeType . Script , } ; let actual ; const predicate = ( node ) => { actual = node ; return true ; } ; const sut = new NodePredicateFilter ( predicate ) ; sut . matcher ( 'nop query' , object ) ; expect ( actual ) . to . deep . equal ( expected ) ; } ) ; describe ( 'returns result from the predicate' , ( ) => { for ( const expected of [ false , true ] ) { it ( expected . toString ( ) , ( ) => { const sut = new NodePredicateFilter ( ( ) => expected ) ; const actual = sut . matcher ( 'nop query' , getExistingNode ( ) ) ; expect ( actual ) . to . equal ( expected ) ; } ) ; } } ) ; } ) ; function getExistingNode ( ) { return { id : 'script' , data : { text : 'script-text' , type : NodeType . Script , documentationUrls : [ ] , isReversible : false , } , states : undefined , children : [ ] , } ; }