diff options
author | 2023-03-17 18:49:41 +0800 | |
---|---|---|
committer | 2023-03-17 03:49:41 -0700 | |
commit | c5f2b4264993739440f73d166280c9ec74e27c1c (patch) | |
tree | ae7acff72ecadb190bf84714b34fa1ad8dabedf9 /test/js | |
parent | 37293cb26a8239d4f387218a1fdadc522787835f (diff) | |
download | bun-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.ts | 33 |
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)); + } + }); }); |