import React from 'react' ; import { useStoreSelector } from './useStoreSelector' ; import { createReducer } from '../..' ; const createMockStore = ( storeName ) => { return createReducer ( storeName , { id : 1 } ) ; } ; describe ( 'check useStoreSelector type infer' , ( ) => { it ( 'has type error with wrong inlined selector argument' , ( ) => { const Cmp = ( ) => { const store = createMockStore ( 'test' ) ; const state = useStoreSelector ( store , ( something ) => something . field ) ; return < div > { ! ! state . x } < /div>; } ; } ) ; it ( 'has type error with wrong inlined selector result' , ( ) => { const Cmp = ( ) => { const store = createMockStore ( 'test' ) ; const state = useStoreSelector ( store , ( something ) => something . id ) ; return < div > { state . hello } < /div>; } ; } ) ; it ( 'has NOT type error with correct inlined selector argument' , ( ) => { const Cmp = ( ) => { const store = createMockStore ( 'test' ) ; const state = useStoreSelector ( store , ( something ) => something . id ) ; return < div > { state } < /div>; } ; } ) ; it ( 'has NOT type error with correct selector result' , ( ) => { const Cmp = ( ) => { const store = createMockStore ( 'test' ) ; const state = useStoreSelector ( store , ( something ) => ( { hello : something . id } ) ) ; return < div > { state . hello } < /div>; } ; } ) ; it ( 'has type error with correct selector result' , ( ) => { const Cmp = ( ) => { const store = createMockStore ( 'test' ) ; const selector = ( a ) => ( { hello : a . x } ) ; const state = useStoreSelector ( store , selector ) ; return < div > { state } < /div>; } ; } ) ; it ( 'has type error with not correct using selector result' , ( ) => { const Cmp = ( ) => { const store = createMockStore ( 'test' ) ; const selector = ( a ) => a . id ; const state = useStoreSelector ( store , selector ) ; return < div > { state . hello } < /div>; } ; } ) ; } ) ;