aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/js/bun/test/expect.test.js16
1 files changed, 16 insertions, 0 deletions
diff --git a/test/js/bun/test/expect.test.js b/test/js/bun/test/expect.test.js
index 804a5339f..4b9e5ec22 100644
--- a/test/js/bun/test/expect.test.js
+++ b/test/js/bun/test/expect.test.js
@@ -1298,6 +1298,16 @@ describe("expect()", () => {
a = { a: 1, b: 2, c: 3 };
b = { a: 1, b: 2 };
expect(a).not.toEqual(b);
+
+ array1 = [1, 2, 3];
+ expect(array1).toEqual(expect.arrayContaining([]));
+ expect(array1).toEqual(expect.arrayContaining([1, 2]));
+ expect(array1).not.toEqual(expect.arrayContaining([1, 2, 4]));
+
+ array2 = [{ a: 1, b: 2 }, { a: { a: 1 } }];
+ expect(array2).toEqual(expect.arrayContaining([{ a: 1, b: 2 }]));
+ expect(array2).toEqual(expect.arrayContaining([{ a: { a: 1 } }]));
+ expect(array2).not.toEqual(expect.arrayContaining([{ a: 2, b: 3 }]));
});
test("symbol based keys in arrays are processed correctly", () => {
@@ -2624,6 +2634,12 @@ describe("expect()", () => {
expect({ a: [1, 2, 3] }).toMatchObject({ a: [1, 2, 3] });
expect({ a: [1, 2, 4] }).not.toMatchObject({ a: [1, 2, 3] });
+ expect({ a: [1, 2, 3] }).toMatchObject({ a: expect.arrayContaining([1, 2]) });
+ expect({ a: [1, 2, 3] }).not.toMatchObject({ a: expect.arrayContaining([4]) });
+ expect({ a: ['hello', 'world'] }).toMatchObject({ a: expect.arrayContaining([]) });
+ expect({ a: ['hello', 'world'] }).toMatchObject({ a: expect.arrayContaining(['world']) });
+ expect({ a: ['hello', 'world'] }).not.toMatchObject({ a: expect.arrayContaining(['hello', 'mars']) });
+
expect([]).toMatchObject([]);
expect([]).toMatchObject({});
expect({}).not.toMatchObject([]);