-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
64 additions
and
63 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,77 +1,78 @@ | ||
local flipbook = script:FindFirstAncestor("flipbook") | ||
|
||
local JestGlobals = require(flipbook.Packages.Dev.JestGlobals) | ||
local types = require(flipbook.Explorer.types) | ||
local filterComponentTreeNode = require(script.Parent.filterComponentTreeNode) | ||
|
||
return function() | ||
local filterComponentTreeNode = require(script.Parent.filterComponentTreeNode) | ||
local expect = JestGlobals.expect | ||
local test = JestGlobals.test | ||
|
||
it("should return true when the query does not match the story name", function() | ||
local target: types.ComponentTreeNode = { | ||
children = {}, | ||
name = "test", | ||
icon = "story", | ||
} | ||
local query = "other" | ||
test("return true when the query does not match the story name", function() | ||
local target: types.ComponentTreeNode = { | ||
children = {}, | ||
name = "test", | ||
icon = "story", | ||
} | ||
local query = "other" | ||
|
||
local result = filterComponentTreeNode(target, query) | ||
expect(result).to.equal(true) | ||
end) | ||
local result = filterComponentTreeNode(target, query) | ||
expect(result).toBe(true) | ||
end) | ||
|
||
it("should return false the query matches the story name", function() | ||
local target: types.ComponentTreeNode = { | ||
children = {}, | ||
name = "test", | ||
icon = "story", | ||
} | ||
local query = "tes" | ||
test("return false the query matches the story name", function() | ||
local target: types.ComponentTreeNode = { | ||
children = {}, | ||
name = "test", | ||
icon = "story", | ||
} | ||
local query = "tes" | ||
|
||
local result = filterComponentTreeNode(target, query) | ||
expect(result).to.equal(false) | ||
end) | ||
local result = filterComponentTreeNode(target, query) | ||
expect(result).toBe(false) | ||
end) | ||
|
||
it("should return true when the filter does not match any of node in tree", function() | ||
local target: types.ComponentTreeNode = { | ||
children = { | ||
{ | ||
children = {}, | ||
name = "test", | ||
icon = "story", | ||
}, | ||
{ | ||
children = {}, | ||
name = "folder", | ||
icon = "folder", | ||
}, | ||
test("return true when the filter does not match any of node in tree", function() | ||
local target: types.ComponentTreeNode = { | ||
children = { | ||
{ | ||
children = {}, | ||
name = "test", | ||
icon = "story", | ||
}, | ||
name = "storybook", | ||
icon = "storybook", | ||
} | ||
local query = "other" | ||
{ | ||
children = {}, | ||
name = "folder", | ||
icon = "folder", | ||
}, | ||
}, | ||
name = "storybook", | ||
icon = "storybook", | ||
} | ||
local query = "other" | ||
|
||
local result = filterComponentTreeNode(target, query) | ||
expect(result).to.equal(true) | ||
end) | ||
local result = filterComponentTreeNode(target, query) | ||
expect(result).toBe(true) | ||
end) | ||
|
||
it("should return false when a filter match at least one of nodes in tree", function() | ||
local target: types.ComponentTreeNode = { | ||
children = { | ||
{ | ||
children = {}, | ||
name = "test", | ||
icon = "story", | ||
}, | ||
{ | ||
children = {}, | ||
name = "folder", | ||
icon = "folder", | ||
}, | ||
test("return false when a filter match at least one of nodes in tree", function() | ||
local target: types.ComponentTreeNode = { | ||
children = { | ||
{ | ||
children = {}, | ||
name = "test", | ||
icon = "story", | ||
}, | ||
{ | ||
children = {}, | ||
name = "folder", | ||
icon = "folder", | ||
}, | ||
name = "storybook", | ||
icon = "storybook", | ||
} | ||
local query = "tes" | ||
}, | ||
name = "storybook", | ||
icon = "storybook", | ||
} | ||
local query = "tes" | ||
|
||
local result = filterComponentTreeNode(target, query) | ||
expect(result).to.equal(false) | ||
end) | ||
end | ||
local result = filterComponentTreeNode(target, query) | ||
expect(result).toBe(false) | ||
end) |