Skip to content

Commit

Permalink
chore: add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
crutchcorn committed Dec 1, 2024
1 parent 4ec258b commit ce6f794
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions packages/store/tests/scheduler.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,4 +122,26 @@ describe('Scheduler logic', () => {
expect(__storeToDerived.get(count)).toContain(double)
expect(__derivedToStore.get(double)).toContain(count)
})

test('should register graph items in the right direction order', () => {
const count = new Store<any, any>(12)

const double = new Derived<any, any>({
deps: [count],
fn: () => {
return count.state * 2
},
})

const halfDouble = new Derived<any, any>({
deps: [double],
fn: () => {
return double.state / 2
},
})

halfDouble.registerOnGraph()

expect(Array.from(__storeToDerived.get(count)!)).toEqual([double, halfDouble])
})
})

0 comments on commit ce6f794

Please sign in to comment.