From a980c9588c48014a5ba1ae0a791e2d535fe7fdbc Mon Sep 17 00:00:00 2001 From: Jonathan MASSUCHETTI Date: Tue, 3 Dec 2024 16:01:24 +0100 Subject: [PATCH] test: check `shouldFollow` function receive all expected arguments --- .../depthFirstSearch/depthFirstSearch.spec.ts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/algorithms/depthFirstSearch/depthFirstSearch.spec.ts b/src/algorithms/depthFirstSearch/depthFirstSearch.spec.ts index 755e1a4..6802c3a 100644 --- a/src/algorithms/depthFirstSearch/depthFirstSearch.spec.ts +++ b/src/algorithms/depthFirstSearch/depthFirstSearch.spec.ts @@ -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(); + + 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; + }, + }); + }); });