Skip to content

Commit

Permalink
Merge pull request #100 from JesusTheHun/test/shouldFollow
Browse files Browse the repository at this point in the history
Add a test to make sure that the function `shouldFollow` receives all expected arguments
  • Loading branch information
curran authored Dec 4, 2024
2 parents a8453be + a980c95 commit 1c27c88
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/algorithms/depthFirstSearch/depthFirstSearch.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,21 @@ describe('depthFirstSearch', () => {
expect(nodes).toContain('b');
expect(nodes).toContain('e');
});

it('should pass all the expected args to the shouldFollow function', function () {
expect.hasAssertions();

const graph = new Graph<string, { type: string }>();

graph.addEdge('a', 'b', { props: { type: 'foo' } });

depthFirstSearch(graph, {
shouldFollow: ({ source, target, props }) => {
expect(source).toEqual(expect.any(String));
expect(target).toEqual(expect.any(String));
expect(props).toEqual({ type: 'foo' });
return true;
},
});
});
});

0 comments on commit 1c27c88

Please sign in to comment.