Skip to content

Commit

Permalink
prefer arrivedAt
Browse files Browse the repository at this point in the history
  • Loading branch information
krisl committed Jul 9, 2023
1 parent e039da6 commit bc2379d
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/graph.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,9 @@ describe('ngraph', () => {
node => node.data,
getLockForLink,
node => node.id as string)("agent1").makePathLocker
const lockNext = makeLocker(path)((nextNodes) => { forwardPath = nextNodes }).lockNext
const locker = makeLocker(path)((nextNodes) => { forwardPath = nextNodes })
const arrivedAt = (nodeId: string) =>
locker.arrivedAt(path.findIndex(node => node.id === nodeId))

// all nodes are unlocked
expect(nodeA.data.isLocked()).toBeFalsy()
Expand All @@ -255,23 +257,23 @@ describe('ngraph', () => {
expect(forwardPath).toEqual([])

// progressing to the first node locks it, and the next
lockNext('a')
arrivedAt('a')
expect(nodeA.data.isLocked()).toBeTruthy()
expect(nodeB.data.isLocked()).toBeTruthy()
expect(nodeC.data.isLocked()).toBeFalsy()
expect(forwardPath).toEqual([{index: 0, node: 'a'}, {index: 1, node: 'b'}])

// progressing to the second node locks it, and the next
// and unlocks nodes behind it
lockNext('b')
arrivedAt('b')
expect(nodeA.data.isLocked()).toBeFalsy()
expect(nodeB.data.isLocked()).toBeTruthy()
expect(nodeC.data.isLocked()).toBeTruthy()
expect(forwardPath).toEqual([{index: 1, node: 'b'}, {index: 2, node: 'c'}])

// progressing to the last node locks it
// and unlocks nodes behind it
lockNext('c')
arrivedAt('c')
expect(nodeA.data.isLocked()).toBeFalsy()
expect(nodeB.data.isLocked()).toBeFalsy()
expect(nodeC.data.isLocked()).toBeTruthy()
Expand Down

0 comments on commit bc2379d

Please sign in to comment.