improve: filter as a plugin (#4255)
This commit is contained in:
25
test/core/plugins/filter/opsFilter.js
Normal file
25
test/core/plugins/filter/opsFilter.js
Normal file
@@ -0,0 +1,25 @@
|
||||
import { Map } from "immutable"
|
||||
import opsFilter from "corePlugins/filter/opsFilter"
|
||||
import expect from "expect"
|
||||
|
||||
describe("opsFilter", function() {
|
||||
const taggedOps = Map([["pet"], ["store"], ["user"]])
|
||||
|
||||
it("should filter taggedOps by tag name", function () {
|
||||
const filtered = opsFilter(taggedOps, "sto")
|
||||
|
||||
expect(filtered.size).toEqual(1)
|
||||
})
|
||||
|
||||
it("should return all taggedOps when search phrase is empty", function () {
|
||||
const filtered = opsFilter(taggedOps, "")
|
||||
|
||||
expect(filtered.size).toEqual(taggedOps.size)
|
||||
})
|
||||
|
||||
it("should return empty result when there is no match", function () {
|
||||
const filtered = opsFilter(taggedOps, "NoMatch")
|
||||
|
||||
expect(filtered.size).toEqual(0)
|
||||
})
|
||||
})
|
||||
@@ -5,6 +5,7 @@ import System from "core/system"
|
||||
import { fromJS } from "immutable"
|
||||
import { render } from "enzyme"
|
||||
import ViewPlugin from "core/plugins/view/index.js"
|
||||
import filterPlugin from "core/plugins/filter/index.js"
|
||||
import { connect, Provider } from "react-redux"
|
||||
|
||||
describe("bound system", function(){
|
||||
@@ -264,6 +265,22 @@ describe("bound system", function(){
|
||||
|
||||
})
|
||||
|
||||
describe("fn", function() {
|
||||
|
||||
it("should return helper functions", function () {
|
||||
// Given
|
||||
const system = new System({
|
||||
plugins: [
|
||||
filterPlugin
|
||||
]
|
||||
})
|
||||
|
||||
// When
|
||||
const fn = system.getSystem().fn.opsFilter
|
||||
expect(typeof fn).toEqual("function")
|
||||
})
|
||||
})
|
||||
|
||||
describe("selectors", function(){
|
||||
|
||||
it("should have the first arg be the nested state, and all other args to follow", function(){
|
||||
|
||||
Reference in New Issue
Block a user