This repository has been archived by the owner on Sep 7, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 248
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added:
statinamic/lib/enhance-collection
can now filter keys using …
…a RegExp
- Loading branch information
Showing
3 changed files
with
54 additions
and
1 deletion.
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
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,42 @@ | ||
import tape from "tape" | ||
|
||
import enhanceCollection from ".." | ||
|
||
tape("statinamic/lib/enhance-collection", (test) => { | ||
|
||
const collec = [ | ||
{ k: "ey" }, | ||
{ k: "ay" }, | ||
{ k: "ei" }, | ||
{ k: "eye" }, | ||
] | ||
|
||
test.deepEqual( | ||
enhanceCollection( | ||
collec, | ||
{ | ||
filter: { k: "ey" }, | ||
} | ||
), | ||
[ | ||
{ k: "ey" }, | ||
], | ||
"should filter by object { key: string }" | ||
) | ||
|
||
test.deepEqual( | ||
enhanceCollection( | ||
collec, | ||
{ | ||
filter: { k: /y$/ }, | ||
} | ||
), | ||
[ | ||
{ k: "ey" }, | ||
{ k: "ay" }, | ||
], | ||
"should filter by object { key: regexp }" | ||
) | ||
|
||
test.end() | ||
}) |
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