diff --git a/package.json b/package.json index 86f7bec..8376bb9 100644 --- a/package.json +++ b/package.json @@ -28,7 +28,7 @@ "check:deps": "dependency-cruiser src", "changelog": "auto-changelog", "coverage:badge": "istanbul-badges-readme", - "ci": "env && npm run lint && npm run build && npm run test && git fetch --tags && npm run changelog" + "ci": "env && npm run lint && npm run build && npm run update:individuals && npm run test && git fetch --tags && npm run changelog" }, "repository": { "type": "git", diff --git a/test/integration/avl-tree.test.ts b/test/integration/avl-tree.test.ts index 7e65b6d..6064a97 100644 --- a/test/integration/avl-tree.test.ts +++ b/test/integration/avl-tree.test.ts @@ -31,12 +31,12 @@ describe('AVL Tree Test', () => { // node15 has type problem. After the uniform design, the generics of containers (DirectedGraph, BST) are based on the type of value. However, this design has a drawback: when I attempt to inherit from the Vertex or BSTNode classes, the types of the results obtained by all methods are those of the parent class. expect(node15?.val).toBe(15); - const dfs = tree.DFS('in', 'node'); + const dfs = tree.dfs('in', 'node'); expect(dfs[0].key).toBe(1); expect(dfs[dfs.length - 1].key).toBe(16); tree.perfectlyBalance(); - const bfs = tree.BFS('node'); + const bfs = tree.bfs('node'); expect(tree.isPerfectlyBalanced()).toBe(true); expect(bfs[0].key).toBe(8); expect(bfs[bfs.length - 1].key).toBe(16); @@ -95,12 +95,12 @@ describe('AVL Tree Test', () => { expect(tree.getHeight()).toBe(1); expect(tree.isAVLBalanced()).toBe(true); - const lastBFSIds = tree.BFS(); + const lastBFSIds = tree.bfs(); expect(lastBFSIds[0]).toBe(12); expect(lastBFSIds[1]).toBe(2); expect(lastBFSIds[2]).toBe(16); - const lastBFSNodes = tree.BFS('node'); + const lastBFSNodes = tree.bfs('node'); expect(lastBFSNodes[0].key).toBe(12); expect(lastBFSNodes[1].key).toBe(2); expect(lastBFSNodes[2].key).toBe(16); diff --git a/test/integration/bst.test.ts b/test/integration/bst.test.ts index 3a82466..51abf5a 100644 --- a/test/integration/bst.test.ts +++ b/test/integration/bst.test.ts @@ -44,14 +44,14 @@ describe('Individual package BST operations test', () => { const node11 = bst.get(11); expect(node11).toBeInstanceOf(BSTNode); - const dfsInorderNodes = bst.DFS('in', 'node'); + const dfsInorderNodes = bst.dfs('in', 'node'); expect(dfsInorderNodes[0].key).toBe(1); expect(dfsInorderNodes[dfsInorderNodes.length - 1].key).toBe(16); bst.perfectlyBalance(); expect(bst.isPerfectlyBalanced()).toBe(true); - const bfsNodesAfterBalanced = bst.BFS('node'); + const bfsNodesAfterBalanced = bst.bfs('node'); expect(bfsNodesAfterBalanced[0].key).toBe(8); expect(bfsNodesAfterBalanced[bfsNodesAfterBalanced.length - 1].key).toBe(16); @@ -169,12 +169,12 @@ describe('Individual package BST operations test', () => { expect(bst.isAVLBalanced()).toBe(false); - const bfsIDs = bst.BFS(); + const bfsIDs = bst.bfs(); expect(bfsIDs[0]).toBe(2); expect(bfsIDs[1]).toBe(12); expect(bfsIDs[2]).toBe(16); - const bfsNodes = bst.BFS('node'); + const bfsNodes = bst.bfs('node'); expect(bfsNodes[0].key).toBe(2); expect(bfsNodes[1].key).toBe(12); expect(bfsNodes[2].key).toBe(16); @@ -242,14 +242,14 @@ describe('Individual package BST operations test', () => { const node11 = objBST.get(11); expect(node11).toBeInstanceOf(BSTNode); - const dfsInorderNodes = objBST.DFS('in', 'node'); + const dfsInorderNodes = objBST.dfs('in', 'node'); expect(dfsInorderNodes[0].key).toBe(1); expect(dfsInorderNodes[dfsInorderNodes.length - 1].key).toBe(16); objBST.perfectlyBalance(); expect(objBST.isPerfectlyBalanced()).toBe(true); - const bfsNodesAfterBalanced = objBST.BFS('node'); + const bfsNodesAfterBalanced = objBST.bfs('node'); expect(bfsNodesAfterBalanced[0].key).toBe(8); expect(bfsNodesAfterBalanced[bfsNodesAfterBalanced.length - 1].key).toBe(16); @@ -367,12 +367,12 @@ describe('Individual package BST operations test', () => { expect(objBST.isAVLBalanced()).toBe(false); - const bfsIDs = objBST.BFS(); + const bfsIDs = objBST.bfs(); expect(bfsIDs[0]).toBe(2); expect(bfsIDs[1]).toBe(12); expect(bfsIDs[2]).toBe(16); - const bfsNodes = objBST.BFS('node'); + const bfsNodes = objBST.bfs('node'); expect(bfsNodes[0].key).toBe(2); expect(bfsNodes[1].key).toBe(12); expect(bfsNodes[2].key).toBe(16); diff --git a/test/unit/data-structures/graph/directed-graph.test.ts b/test/unit/data-structures/graph/directed-graph.test.ts index 9c8dae5..ce89d66 100644 --- a/test/unit/data-structures/graph/directed-graph.test.ts +++ b/test/unit/data-structures/graph/directed-graph.test.ts @@ -1,4 +1,4 @@ -import {DirectedEdge, DirectedGraph, DirectedVertex, VertexId} from '../../../../src'; +import {DirectedEdge, DirectedGraph, DirectedVertex, VertexKey} from '../../../../src'; describe('DirectedGraph Operation Test', () => { let graph: DirectedGraph; @@ -63,7 +63,7 @@ describe('DirectedGraph Operation Test', () => { }); class MyVertex extends DirectedVertex { - constructor(key: VertexId, val?: V) { + constructor(key: VertexKey, val?: V) { super(key, val); this._data = val; } @@ -80,7 +80,7 @@ class MyVertex extends DirectedVertex { } class MyEdge extends DirectedEdge { - constructor(v1: VertexId, v2: VertexId, weight?: number, val?: E) { + constructor(v1: VertexKey, v2: VertexKey, weight?: number, val?: E) { super(v1, v2, weight, val); this._data = val; } @@ -97,11 +97,11 @@ class MyEdge extends DirectedEdge { } class MyDirectedGraph, E extends MyEdge> extends DirectedGraph { - createVertex(key: VertexId, val: V['val']): V { + createVertex(key: VertexKey, val: V['val']): V { return new MyVertex(key, val) as V; } - createEdge(src: VertexId, dest: VertexId, weight?: number, val?: E['val']): E { + createEdge(src: VertexKey, dest: VertexKey, weight?: number, val?: E['val']): E { return new MyEdge(src, dest, weight ?? 1, val) as E; } } diff --git a/test/unit/data-structures/graph/index.ts b/test/unit/data-structures/graph/index.ts deleted file mode 100644 index 552cec7..0000000 --- a/test/unit/data-structures/graph/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './directed-graph.test'; -export * from './undirected-graph.test'; diff --git a/test/unit/data-structures/graph/overall.test.ts b/test/unit/data-structures/graph/overall.test.ts index 19bebdb..883ff5d 100644 --- a/test/unit/data-structures/graph/overall.test.ts +++ b/test/unit/data-structures/graph/overall.test.ts @@ -29,8 +29,8 @@ describe('Overall Graph Operation Test', () => { graph.addEdge('A', 'B'); graph.addEdge('B', 'C'); - const topologicalOrderIds = graph.topologicalSort(); - expect(topologicalOrderIds).toEqual(['A', 'B', 'C']); + const topologicalOrderKeys = graph.topologicalSort(); + expect(topologicalOrderKeys).toEqual(['A', 'B', 'C']); }); it('Overall UndirectedGraph Operation Test', () => { const graph = new UndirectedGraph(); diff --git a/test/unit/data-structures/linked-list/index.ts b/test/unit/data-structures/linked-list/index.ts deleted file mode 100644 index 3b50503..0000000 --- a/test/unit/data-structures/linked-list/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -export * from './singly-linked-list.test'; -export * from './doubly-linked-list.test'; -export * from './linked-list.test'; -export * from './skip-linked-list.test';