Skip to content

Commit

Permalink
Tests: attempt to reduce chance of race condition
Browse files Browse the repository at this point in the history
  • Loading branch information
lovell committed Dec 13, 2023
1 parent 3a0c375 commit c9e3996
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions test/unit/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,19 @@ const sharp = require('../../');

describe('Utilities', function () {
describe('Cache', function () {
it('Can be disabled', function () {
sharp.cache(false);
const cache = sharp.cache(false);
assert.strictEqual(cache.memory.current, 0);
assert.strictEqual(cache.memory.max, 0);
assert.strictEqual(typeof cache.memory.high, 'number');
assert.strictEqual(cache.files.current, 0);
assert.strictEqual(cache.files.max, 0);
assert.strictEqual(cache.items.current, 0);
assert.strictEqual(cache.items.max, 0);
it('Can be disabled', function (done) {
queueMicrotask(() => {
sharp.cache(false);
const cache = sharp.cache(false);
assert.strictEqual(cache.memory.current, 0);
assert.strictEqual(cache.memory.max, 0);
assert.strictEqual(typeof cache.memory.high, 'number');
assert.strictEqual(cache.files.current, 0);
assert.strictEqual(cache.files.max, 0);
assert.strictEqual(cache.items.current, 0);
assert.strictEqual(cache.items.max, 0);
done();
});
});
it('Can be enabled with defaults', function () {
const cache = sharp.cache(true);
Expand Down

0 comments on commit c9e3996

Please sign in to comment.