aboutsummaryrefslogtreecommitdiff
path: root/test/js
diff options
context:
space:
mode:
authorGravatar zhiyuan <32867472+zhiyuang@users.noreply.github.com> 2023-03-17 18:49:41 +0800
committerGravatar GitHub <noreply@github.com> 2023-03-17 03:49:41 -0700
commitc5f2b4264993739440f73d166280c9ec74e27c1c (patch)
treeae7acff72ecadb190bf84714b34fa1ad8dabedf9 /test/js
parent37293cb26a8239d4f387218a1fdadc522787835f (diff)
downloadbun-c5f2b4264993739440f73d166280c9ec74e27c1c.tar.gz
bun-c5f2b4264993739440f73d166280c9ec74e27c1c.tar.zst
bun-c5f2b4264993739440f73d166280c9ec74e27c1c.zip
Feat(test): add toMatch (#2404)
Diffstat (limited to 'test/js')
-rw-r--r--test/js/bun/test/expect.test.ts33
1 files changed, 33 insertions, 0 deletions
diff --git a/test/js/bun/test/expect.test.ts b/test/js/bun/test/expect.test.ts
index 9a70aca0a..756e8aaca 100644
--- a/test/js/bun/test/expect.test.ts
+++ b/test/js/bun/test/expect.test.ts
@@ -45,4 +45,37 @@ describe("expect()", () => {
test(label, () => expect(value).toBeInstanceOf(instanceOf));
}
});
+
+ describe("toMatch()", () => {
+ const tests = [
+ {
+ label: "reguler expression",
+ value: "123",
+ matched: /123/,
+ },
+ {
+ label: "reguler expression object",
+ value: "123",
+ matched: new RegExp("123"),
+ },
+ {
+ label: "substring",
+ value: "123",
+ matched: "12",
+ },
+ {
+ label: "substring emojis",
+ value: "πŸ‘πŸ‘Ž",
+ matched: "πŸ‘"
+ },
+ {
+ label: "substring UTF-16",
+ value: "πŸ˜€ πŸ˜ƒ πŸ˜„ 😁 πŸ˜† πŸ˜… πŸ˜‚ 🀣 πŸ₯² ☺️ 😊 πŸ˜‡ πŸ™‚",
+ matched: "πŸ₯² ☺️ 😊"
+ },
+ ];
+ for (const { label, value, matched } of tests) {
+ test(label, () => expect(value).toMatch(matched));
+ }
+ });
});