-
Notifications
You must be signed in to change notification settings - Fork 9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: test opsFilter related to filterConfig
- Loading branch information
Showing
1 changed file
with
149 additions
and
11 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -1,24 +1,162 @@ | ||
import { Map } from "immutable" | ||
import opsFilter from "corePlugins/filter/opsFilter" | ||
|
||
describe("opsFilter", function() { | ||
const taggedOps = Map([["pet"], ["store"], ["user"]]) | ||
describe("opsFilter", () => { | ||
const taggedOps = Map([["pet"], ["store"], ["user"], ["user word"]]) | ||
|
||
it("should filter taggedOps by tag name", function () { | ||
const filtered = opsFilter(taggedOps, "sto") | ||
describe("with default filterConfig", () => { | ||
it("should filter taggedOps by tag name", () => { | ||
const filtered = opsFilter(taggedOps, "sto") | ||
|
||
expect(filtered.size).toEqual(1) | ||
expect(filtered.size).toEqual(1) | ||
}) | ||
|
||
it("should filter taggedOps using case sensitive matching", () => { | ||
const filtered = opsFilter(taggedOps, "Sto") | ||
|
||
expect(filtered.size).toEqual(0) | ||
}) | ||
|
||
it("should return all taggedOps when search phrase is empty", () => { | ||
const filtered = opsFilter(taggedOps, "") | ||
|
||
expect(filtered.size).toEqual(taggedOps.size) | ||
}) | ||
|
||
it("should return empty result when there is no match", () => { | ||
const filtered = opsFilter(taggedOps, "NoMatch") | ||
|
||
expect(filtered.size).toEqual(0) | ||
}) | ||
|
||
it("should not use regex matching", () => { | ||
const filtered = opsFilter(taggedOps, ".*") | ||
|
||
expect(filtered.size).toEqual(0) | ||
}) | ||
}) | ||
|
||
it("should return all taggedOps when search phrase is empty", function () { | ||
const filtered = opsFilter(taggedOps, "") | ||
describe("with regex matching", () => { | ||
const regexFilterConfig = { | ||
isRegexFilter: true, | ||
matchCase: true, | ||
matchWords: false, | ||
} | ||
it("should filter taggedOps by tag name", () => { | ||
const filtered = opsFilter(taggedOps, "st.", regexFilterConfig) | ||
|
||
expect(filtered.size).toEqual(1) | ||
}) | ||
|
||
it("should filter taggedOps using case sensitive matching", () => { | ||
const filtered = opsFilter(taggedOps, "St.", regexFilterConfig) | ||
|
||
expect(filtered.size).toEqual(taggedOps.size) | ||
expect(filtered.size).toEqual(0) | ||
}) | ||
|
||
it("should return all taggedOps when search phrase is empty", () => { | ||
const filtered = opsFilter(taggedOps, "", regexFilterConfig) | ||
|
||
expect(filtered.size).toEqual(taggedOps.size) | ||
}) | ||
|
||
it("should return empty result when there is no match", () => { | ||
const filtered = opsFilter(taggedOps, "NoM.tch", regexFilterConfig) | ||
|
||
expect(filtered.size).toEqual(0) | ||
}) | ||
|
||
it("should use regex matching", () => { | ||
const filtered = opsFilter(taggedOps, ".*", regexFilterConfig) | ||
|
||
expect(filtered.size).toEqual(taggedOps.size) | ||
}) | ||
}) | ||
|
||
it("should return empty result when there is no match", function () { | ||
const filtered = opsFilter(taggedOps, "NoMatch") | ||
describe("full words matching", () => { | ||
const filterConfig = { | ||
isRegexFilter: false, | ||
matchCase: true, | ||
matchWords: true, | ||
} | ||
const regexFilterConfig = { | ||
isRegexFilter: true, | ||
matchCase: true, | ||
matchWords: true, | ||
} | ||
describe("with default matching", () => { | ||
it("should return empty result if it is a partial match", () => { | ||
const filtered = opsFilter(taggedOps, "sto", filterConfig) | ||
|
||
expect(filtered.size).toEqual(0) | ||
}) | ||
|
||
it("should return full words match result, when string boundary == word boundary", () => { | ||
const filtered = opsFilter(taggedOps, "store", filterConfig) | ||
|
||
expect(filtered.size).toEqual(1) | ||
}) | ||
|
||
it("should return full words match result, when space == word boundary", () => { | ||
const filtered = opsFilter(taggedOps, "user", filterConfig) | ||
|
||
expect(filtered.size).toEqual(2) | ||
}) | ||
|
||
it("should filter taggedOps using case sensitive matching", () => { | ||
const filtered = opsFilter(taggedOps, "Store", filterConfig) | ||
|
||
expect(filtered.size).toEqual(0) | ||
}) | ||
|
||
it("should return all taggedOps when search phrase is empty", () => { | ||
const filtered = opsFilter(taggedOps, "", filterConfig) | ||
|
||
expect(filtered.size).toEqual(taggedOps.size) | ||
}) | ||
|
||
it("should return empty result when there is no match", () => { | ||
const filtered = opsFilter(taggedOps, "NoMatch", filterConfig) | ||
|
||
expect(filtered.size).toEqual(0) | ||
}) | ||
}) | ||
describe("with regex matching", () => { | ||
it("should return empty result if it is a partial match", () => { | ||
const filtered = opsFilter(taggedOps, "st.", regexFilterConfig) | ||
|
||
expect(filtered.size).toEqual(0) | ||
}) | ||
|
||
it("should return full words match result, when string boundary == word boundary", () => { | ||
const filtered = opsFilter(taggedOps, "st.re", regexFilterConfig) | ||
|
||
expect(filtered.size).toEqual(1) | ||
}) | ||
|
||
it("should return full words match result, when space == word boundary", () => { | ||
const filtered = opsFilter(taggedOps, "u.er", regexFilterConfig) | ||
|
||
expect(filtered.size).toEqual(2) | ||
}) | ||
|
||
|
||
it("should filter taggedOps using case sensitive matching", () => { | ||
const filtered = opsFilter(taggedOps, "St.re", regexFilterConfig) | ||
|
||
expect(filtered.size).toEqual(0) | ||
}) | ||
|
||
it("should return all taggedOps when search phrase is empty", () => { | ||
const filtered = opsFilter(taggedOps, "", regexFilterConfig) | ||
|
||
expect(filtered.size).toEqual(taggedOps.size) | ||
}) | ||
it("should return empty result when there is no match", () => { | ||
const filtered = opsFilter(taggedOps, "NoM.tch", filterConfig) | ||
|
||
expect(filtered.size).toEqual(0) | ||
expect(filtered.size).toEqual(0) | ||
}) | ||
}) | ||
}) | ||
}) |