@@ -25,6 +25,15 @@ describe('linkstate', () => {
2525 expect ( linkState ( component , 'testStateKey' ) ) . to . be . a ( 'function' ) ;
2626 } ) ;
2727
28+ it ( 'should be memoized' , ( ) => {
29+ expect ( linkState ( component , 'a' ) ) . to . equal ( linkState ( component , 'a' ) ) ;
30+ expect ( linkState ( component , 'a' , 'x' ) ) . to . equal ( linkState ( component , 'a' , 'x' ) ) ;
31+
32+ expect ( linkState ( component , 'a' ) ) . not . to . equal ( linkState ( component , 'b' ) ) ;
33+ expect ( linkState ( component , 'a' ) ) . not . to . equal ( linkState ( component , 'a' , 'x' ) ) ;
34+ expect ( linkState ( component , 'a' , 'x' ) ) . not . to . equal ( linkState ( component , 'a' , 'y' ) ) ;
35+ } ) ;
36+
2837 describe ( 'linkState without eventPath argument' , ( ) => {
2938 beforeEach ( ( ) => {
3039 linkFunction = linkState ( component , 'testStateKey' ) ;
@@ -110,13 +119,4 @@ describe('linkstate', () => {
110119 expect ( component . setState ) . to . have . been . calledWith ( { 'testStateKey' : 'nestedPathValueFromEvent' } ) ;
111120 } ) ;
112121 } ) ;
113-
114- describe ( 'linkState memoisation' , ( ) => {
115- it ( 'should return the same function when called with the same inputs' , ( ) => {
116- linkFunction = linkState ( component , 'nested.state.key' ) ;
117- const linkFunctionB = linkState ( component , 'nested.state.key' ) ;
118-
119- expect ( linkFunction ) . to . equal ( linkFunctionB ) ;
120- } ) ;
121- } ) ;
122122} ) ;
0 commit comments