-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refs: #2318
- Loading branch information
Torsten Knauf
authored and
Torsten Knauf
committed
Nov 9, 2021
1 parent
dcfa015
commit 4c4dedc
Showing
2 changed files
with
76 additions
and
151 deletions.
There are no files selected for viewing
151 changes: 0 additions & 151 deletions
151
visualization/app/codeCharta/state/nodeSearch.service.spec.ts
This file was deleted.
Oops, something went wrong.
76 changes: 76 additions & 0 deletions
76
visualization/app/codeCharta/state/selectors/searchedNodes/getNodesByGitignorePath.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
import { TEST_FILE_WITH_PATHS } from "../../../util/dataMocks" | ||
import { getNodesByGitignorePath } from "./getNodesByGitignorePath" | ||
|
||
describe("getNodesByGitignorePath", () => { | ||
it("should retrieve no nodes for an empty search", () => { | ||
const searchedNodes = getNodesByGitignorePath(TEST_FILE_WITH_PATHS.map, "") | ||
|
||
expect(searchedNodes.length).toBe(0) | ||
}) | ||
|
||
it("should find nodes based on a wildcard search", () => { | ||
const searchedNodes = getNodesByGitignorePath(TEST_FILE_WITH_PATHS.map, "*small*") | ||
|
||
expect(searchedNodes.length).toBe(2) | ||
expect(searchedNodes[0].path).toBe("/root/Parent Leaf/small leaf") | ||
expect(searchedNodes[1].path).toBe("/root/Parent Leaf/other small leaf") | ||
}) | ||
|
||
it("should find nodes based on string search", () => { | ||
const searchedNodes = getNodesByGitignorePath(TEST_FILE_WITH_PATHS.map, "small") | ||
|
||
expect(searchedNodes.length).toBe(2) | ||
expect(searchedNodes[0].path).toBe("/root/Parent Leaf/small leaf") | ||
expect(searchedNodes[1].path).toBe("/root/Parent Leaf/other small leaf") | ||
}) | ||
|
||
it("should find no nodes based on prefix search with non existing prefix", () => { | ||
const searchedNodes = getNodesByGitignorePath(TEST_FILE_WITH_PATHS.map, "oot/*") | ||
|
||
expect(searchedNodes.length).toBe(0) | ||
}) | ||
|
||
it("should find all nodes based on prefix search with prefix of root node", () => { | ||
const searchedNodes = getNodesByGitignorePath(TEST_FILE_WITH_PATHS.map, "root*") | ||
|
||
expect(searchedNodes.length).toBe(6) | ||
}) | ||
|
||
it("should find nodes based on exact match", () => { | ||
const searchedNodes = getNodesByGitignorePath(TEST_FILE_WITH_PATHS.map, '"/root/Parent Leaf"') | ||
|
||
expect(searchedNodes.length).toBe(4) | ||
expect(searchedNodes[0].path).toBe("/root/Parent Leaf") | ||
expect(searchedNodes[1].path).toBe("/root/Parent Leaf/small leaf") | ||
expect(searchedNodes[2].path).toBe("/root/Parent Leaf/other small leaf") | ||
expect(searchedNodes[3].path).toBe("/root/Parent Leaf/empty folder") | ||
}) | ||
|
||
it("should not ignore a leading whitespace with exact match", () => { | ||
const searchedNodes = getNodesByGitignorePath(TEST_FILE_WITH_PATHS.map, '" /root/Parent Leaf"') | ||
|
||
expect(searchedNodes.length).toBe(0) | ||
}) | ||
|
||
it("should find nodes based on inverted search", () => { | ||
const searchedNodes = getNodesByGitignorePath(TEST_FILE_WITH_PATHS.map, "!leaf") | ||
|
||
expect(searchedNodes.length).toBe(1) | ||
expect(searchedNodes[0].path).toBe("/root") | ||
}) | ||
|
||
it("should find nodes based on multiple inverted search", () => { | ||
const searchedNodes = getNodesByGitignorePath(TEST_FILE_WITH_PATHS.map, " \tsmall, \tbig") | ||
expect(searchedNodes.length).toBe(3) | ||
expect(searchedNodes[0].path).toBe("/root/big leaf") | ||
expect(searchedNodes[1].path).toBe("/root/Parent Leaf/small leaf") | ||
expect(searchedNodes[2].path).toBe("/root/Parent Leaf/other small leaf") | ||
|
||
const invertedSearchedNodes = getNodesByGitignorePath(TEST_FILE_WITH_PATHS.map, "! \tsmall, \tbig") | ||
|
||
expect(invertedSearchedNodes.length).toBe(3) | ||
expect(invertedSearchedNodes[0].path).toBe("/root") | ||
expect(invertedSearchedNodes[1].path).toBe("/root/Parent Leaf") | ||
expect(invertedSearchedNodes[2].path).toBe("/root/Parent Leaf/empty folder") | ||
}) | ||
}) |