From 5a2380d486e78f5c0ff0e5b66ecc46f19c553bfd Mon Sep 17 00:00:00 2001 From: William Chargin Date: Fri, 2 Mar 2018 20:46:35 -0800 Subject: [PATCH] Move `addNode`/`addEdge` tests away from getters (#60) Summary: Nothing big; these were just organized wrong. wchargin-branch: test-reorg --- src/backend/graph.test.js | 44 ++++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/src/backend/graph.test.js b/src/backend/graph.test.js index fbdf7d2..347ab75 100644 --- a/src/backend/graph.test.js +++ b/src/backend/graph.test.js @@ -257,6 +257,29 @@ describe("graph", () => { ).toBeUndefined(); }); + it("gets all nodes", () => { + const expected = [heroNode(), bananasNode(), crabNode(), mealNode()]; + const actual = advancedMealGraph().getAllNodes(); + expectSameSorted(expected, actual); + }); + + it("gets all edges", () => { + const expected = [ + pickEdge(), + grabEdge(), + cookEdge(), + bananasIngredientEdge(), + crabIngredientEdge(), + eatEdge(), + crabLoopEdge(), + duplicateCookEdge(), + ]; + const actual = advancedMealGraph().getAllEdges(); + expectSameSorted(expected, actual); + }); + }); + + describe("creating nodes and edges", () => { it("forbids adding a node with existing address", () => { expect(() => simpleMealGraph().addNode({ @@ -295,27 +318,6 @@ describe("graph", () => { }); }); - it("gets all nodes", () => { - const expected = [heroNode(), bananasNode(), crabNode(), mealNode()]; - const actual = advancedMealGraph().getAllNodes(); - expectSameSorted(expected, actual); - }); - - it("gets all edges", () => { - const expected = [ - pickEdge(), - grabEdge(), - cookEdge(), - bananasIngredientEdge(), - crabIngredientEdge(), - eatEdge(), - crabLoopEdge(), - duplicateCookEdge(), - ]; - const actual = advancedMealGraph().getAllEdges(); - expectSameSorted(expected, actual); - }); - // For the next two test cases: we're documenting this behavior, // though we're not sure if it's the right behavior. Perhaps we want // the namespaces to be forced to be disjoint. In that case, we can