Improve test

This commit is contained in:
Andras Schmelczer 2025-02-23 10:04:27 +00:00
commit 9c61927c1b
No known key found for this signature in database
GPG key ID: FC8F2C3D3D1A718C

View file

@ -58,6 +58,7 @@ describe("Document Lock Operations", () => {
let firstResolved = false; let firstResolved = false;
let secondResolved = false; let secondResolved = false;
let thirdResolved = false;
const firstWaitPromise = waitForDocumentLock(testPath).then(() => { const firstWaitPromise = waitForDocumentLock(testPath).then(() => {
firstResolved = true; firstResolved = true;
@ -67,13 +68,23 @@ describe("Document Lock Operations", () => {
secondResolved = true; secondResolved = true;
}); });
const thirdWaitPromise = waitForDocumentLock(testPath).then(() => {
thirdResolved = true;
});
unlockDocument(testPath); unlockDocument(testPath);
await firstWaitPromise; await firstWaitPromise;
expect(firstResolved).toBe(true); expect(firstResolved).toBe(true);
expect(secondResolved).toBe(false); expect(secondResolved).toBe(false);
expect(thirdResolved).toBe(false);
unlockDocument(testPath); unlockDocument(testPath);
await secondWaitPromise; await secondWaitPromise;
expect(secondResolved).toBe(true); expect(secondResolved).toBe(true);
expect(thirdResolved).toBe(false);
unlockDocument(testPath);
await thirdWaitPromise;
expect(thirdResolved).toBe(true);
}); });
}); });