From 7812601770412fc8de24eb9ab25304693daca3bf Mon Sep 17 00:00:00 2001 From: juner Date: Tue, 18 Nov 2025 13:47:23 +0900 Subject: [PATCH] =?UTF-8?q?=E3=82=A8=E3=83=A9=E3=83=BC=E3=83=86=E3=82=B9?= =?UTF-8?q?=E3=83=88=E3=81=AE=E3=83=81=E3=82=A7=E3=83=83=E3=82=AF=E3=82=92?= =?UTF-8?q?=20=E3=82=A8=E3=83=A9=E3=83=BC=E5=9E=8B=E3=81=8B=E3=82=89?= =?UTF-8?q?=E3=82=82=E3=81=99=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB=E4=BF=AE?= =?UTF-8?q?=E6=AD=A3=E3=80=82=E3=81=BE=E3=81=9F=E3=80=81=20steal:true=20/?= =?UTF-8?q?=20ifAvailable:true=20=E3=81=AE=E3=83=86=E3=82=B9=E3=83=88?= =?UTF-8?q?=E3=82=82=E8=BF=BD=E5=8A=A0=20fix:=20#7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/lock.test.ts | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/lock.test.ts b/src/lock.test.ts index 6fec188..0ab0129 100644 --- a/src/lock.test.ts +++ b/src/lock.test.ts @@ -167,7 +167,7 @@ describe("simple use", () => { await using _ = await request(); const lock2Wait = request({ signal }); controller.abort(); - await expect(lock2Wait).rejects.toThrow("This operation was aborted"); + await expect(lock2Wait).rejects.toThrow(new DOMException("This operation was aborted", "AbortError")); } }); } @@ -206,6 +206,19 @@ describe("simple use", () => { } }); } + { + const name = "steal:true and ifAvailable:true"; + test.concurrent("steal:true and ifAvailable:true", async ({ expect }) => { + const { request } = lock(name); + { + const lockWait = request({ + ifAvailable: true, + steal: true, + }); + expect(lockWait).rejects.toThrow(new DOMException("ifAvailable and steal are mutually exclusive", "NotSupportedError")); + } + }); + } }); describe("hard error pattern", () => { const name = "not found navigator.locks"; @@ -216,7 +229,7 @@ describe("hard error pattern", () => { value: undefined, }); try { - expect(() => lock(name)).toThrow("navigator.locks is not found. required options.locks argument."); + expect(() => lock(name)).toThrow(new Error("navigator.locks is not found. required options.locks argument.")); const { request, query } = lock(name, { locks }); {