summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibJS/Tests
diff options
context:
space:
mode:
authorIdan Horowitz <idan.horowitz@gmail.com>2022-12-01 22:17:43 +0200
committerLinus Groh <mail@linusgroh.de>2022-12-02 13:09:15 +0100
commit9e693304ff4caac4c6e3882a2979f3fdf89f20e4 (patch)
treebbdc2cf0e78cd7cb8d4ce7af79ada831139abe36 /Userland/Libraries/LibJS/Tests
parentfee65f6453186e936e5bd1c4c29e48e4f2e31e99 (diff)
downloadserenity-9e693304ff4caac4c6e3882a2979f3fdf89f20e4.zip
LibJS: Implement Set.prototype.intersection
Diffstat (limited to 'Userland/Libraries/LibJS/Tests')
-rw-r--r--Userland/Libraries/LibJS/Tests/builtins/Set/Set.prototype.intersection.js12
1 files changed, 12 insertions, 0 deletions
diff --git a/Userland/Libraries/LibJS/Tests/builtins/Set/Set.prototype.intersection.js b/Userland/Libraries/LibJS/Tests/builtins/Set/Set.prototype.intersection.js
new file mode 100644
index 0000000000..98ce3f1c96
--- /dev/null
+++ b/Userland/Libraries/LibJS/Tests/builtins/Set/Set.prototype.intersection.js
@@ -0,0 +1,12 @@
+test("basic functionality", () => {
+ expect(Set.prototype.intersection).toHaveLength(1);
+
+ const set1 = new Set(["a", "b", "c"]);
+ const set2 = new Set(["b", "c", "d", "e"]);
+ const intersection1to2 = set1.intersection(set2);
+ const intersection2to1 = set2.intersection(set1);
+ for (const intersectionSet of [intersection1to2, intersection2to1]) {
+ expect(intersectionSet).toHaveSize(2);
+ ["b", "c"].forEach(value => expect(intersectionSet.has(value)).toBeTrue());
+ }
+});