@@ -29,8 +29,14 @@ describe('createAtomStore', () => {
2929 arr : INITIAL_ARR ,
3030 } ;
3131
32- const { useMyTestStoreStore, MyTestStoreProvider, useMyTestStoreValue } =
33- createAtomStore ( initialTestStoreValue , { name : 'myTestStore' as const } ) ;
32+ const {
33+ myTestStoreStore,
34+ useMyTestStoreStore,
35+ MyTestStoreProvider,
36+ useMyTestStoreValue,
37+ } = createAtomStore ( initialTestStoreValue , {
38+ name : 'myTestStore' as const ,
39+ } ) ;
3440
3541 let numRenderCount = 0 ;
3642 const NumRenderer = ( ) => {
@@ -121,6 +127,21 @@ describe('createAtomStore', () => {
121127 ) ;
122128 } ;
123129
130+ let arrNumRenderWithDepsAndAtomCount = 0 ;
131+ const ArrNumRendererWithDepsAndAtom = ( ) => {
132+ arrNumRenderWithDepsAndAtomCount += 1 ;
133+ const store = useMyTestStoreStore ( ) ;
134+ const numAtom = myTestStoreStore . atom . num ;
135+ const num = store . useAtomValue ( numAtom ) ;
136+ const arrAtom = myTestStoreStore . atom . arr ;
137+ const arrNum = store . useAtomValue ( arrAtom , ( v ) => v [ num ] , [ num ] ) ;
138+ return (
139+ < div >
140+ < div > arrNumWithDepsAndAtom: { arrNum } </ div >
141+ </ div >
142+ ) ;
143+ } ;
144+
124145 const BadSelectorRenderer = ( ) => {
125146 const arr0 = useMyTestStoreStore ( ) . useArrValue ( ( v ) => v [ 0 ] ) ;
126147 return < div > { arr0 } </ div > ;
@@ -177,6 +198,7 @@ describe('createAtomStore', () => {
177198 < ArrNumRenderer />
178199 < ArrNumRendererWithOneHook />
179200 < ArrNumRendererWithDeps />
201+ < ArrNumRendererWithDepsAndAtom />
180202 < Buttons />
181203 </ MyTestStoreProvider >
182204 ) ;
@@ -190,6 +212,7 @@ describe('createAtomStore', () => {
190212 expect ( arrNumRenderCount ) . toBe ( 2 ) ;
191213 expect ( arrNumRenderCountWithOneHook ) . toBe ( 2 ) ;
192214 expect ( arrNumRenderWithDepsCount ) . toBe ( 2 ) ;
215+ expect ( arrNumRenderWithDepsAndAtomCount ) . toBe ( 2 ) ;
193216 expect ( getByText ( 'arrNum: alice' ) ) . toBeInTheDocument ( ) ;
194217 expect ( getByText ( 'arrNumWithDeps: alice' ) ) . toBeInTheDocument ( ) ;
195218
@@ -202,6 +225,7 @@ describe('createAtomStore', () => {
202225 expect ( arrNumRenderCount ) . toBe ( 5 ) ;
203226 expect ( arrNumRenderCountWithOneHook ) . toBe ( 5 ) ;
204227 expect ( arrNumRenderWithDepsCount ) . toBe ( 5 ) ;
228+ expect ( arrNumRenderWithDepsAndAtomCount ) . toBe ( 5 ) ;
205229 expect ( getByText ( 'arrNum: bob' ) ) . toBeInTheDocument ( ) ;
206230 expect ( getByText ( 'arrNumWithDeps: bob' ) ) . toBeInTheDocument ( ) ;
207231
@@ -214,6 +238,7 @@ describe('createAtomStore', () => {
214238 expect ( arrNumRenderCount ) . toBe ( 5 ) ;
215239 expect ( arrNumRenderCountWithOneHook ) . toBe ( 5 ) ;
216240 expect ( arrNumRenderWithDepsCount ) . toBe ( 5 ) ;
241+ expect ( arrNumRenderWithDepsAndAtomCount ) . toBe ( 5 ) ;
217242 expect ( getByText ( 'arrNum: bob' ) ) . toBeInTheDocument ( ) ;
218243 expect ( getByText ( 'arrNumWithDeps: bob' ) ) . toBeInTheDocument ( ) ;
219244
@@ -226,6 +251,7 @@ describe('createAtomStore', () => {
226251 expect ( arrNumRenderCount ) . toBe ( 5 ) ;
227252 expect ( arrNumRenderCountWithOneHook ) . toBe ( 5 ) ;
228253 expect ( arrNumRenderWithDepsCount ) . toBe ( 5 ) ;
254+ expect ( arrNumRenderWithDepsAndAtomCount ) . toBe ( 5 ) ;
229255 expect ( getByText ( 'arrNum: bob' ) ) . toBeInTheDocument ( ) ;
230256 expect ( getByText ( 'arrNumWithDeps: bob' ) ) . toBeInTheDocument ( ) ;
231257
@@ -238,6 +264,7 @@ describe('createAtomStore', () => {
238264 expect ( arrNumRenderCount ) . toBe ( 8 ) ;
239265 expect ( arrNumRenderCountWithOneHook ) . toBe ( 8 ) ;
240266 expect ( arrNumRenderWithDepsCount ) . toBe ( 8 ) ;
267+ expect ( arrNumRenderWithDepsAndAtomCount ) . toBe ( 8 ) ;
241268 expect ( getByText ( 'arrNum: ava' ) ) . toBeInTheDocument ( ) ;
242269 expect ( getByText ( 'arrNumWithDeps: ava' ) ) . toBeInTheDocument ( ) ;
243270 } ) ;
0 commit comments