migrate tests to node:test
This commit is contained in:
@@ -1,13 +1,12 @@
|
||||
/* global it, describe, before, after */
|
||||
import { describe, it, before, after } from 'node:test';
|
||||
|
||||
import BoxError from '../boxerror.js';
|
||||
import common from './common.js';
|
||||
import expect from 'expect.js';
|
||||
import assert from 'node:assert/strict';
|
||||
import safe from 'safetydance';
|
||||
import locks from '../locks.js';
|
||||
|
||||
describe('Locks', function () {
|
||||
this.timeout(20000);
|
||||
describe('Locks', { timeout: 20000 }, function () {
|
||||
|
||||
const { setup, cleanup } = common;
|
||||
|
||||
@@ -24,7 +23,7 @@ describe('Locks', function () {
|
||||
|
||||
it('cannot reacquire lock foo', async function () {
|
||||
const [error] = await safe(locks.acquire('foo'));
|
||||
expect(error.reason).to.be(BoxError.BAD_STATE);
|
||||
assert.equal(error.reason, BoxError.BAD_STATE);
|
||||
});
|
||||
|
||||
it('cannot reacquire after release', async function () {
|
||||
@@ -43,7 +42,7 @@ describe('Locks', function () {
|
||||
const startTime = Date.now();
|
||||
await locks.wait('tasklock'); // retries only in 10s
|
||||
const endTime = Date.now();
|
||||
expect(endTime - startTime).to.be.greaterThan(9900);
|
||||
expect(endTime - startTime).to.be.lessThan(10100);
|
||||
assert.ok((endTime - startTime) > (9900));
|
||||
assert.ok((endTime - startTime) < (10100));
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user