Skip to content

Commit

Permalink
Use node:assert
Browse files Browse the repository at this point in the history
  • Loading branch information
asamuzaK committed Dec 29, 2024
1 parent 357e3f5 commit 18010b4
Show file tree
Hide file tree
Showing 21 changed files with 2,264 additions and 2,051 deletions.
227 changes: 112 additions & 115 deletions test/background-main.test.js

Large diffs are not rendered by default.

62 changes: 29 additions & 33 deletions test/bookmark.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
/* eslint-disable import-x/order */

/* api */
import sinon from 'sinon';
import { assert } from 'chai';
import { strict as assert } from 'node:assert';
import { afterEach, beforeEach, describe, it } from 'mocha';
import sinon from 'sinon';
import { browser, createJsdom } from './mocha/setup.js';

/* test */
Expand Down Expand Up @@ -44,10 +44,6 @@ describe('bookmark', () => {
browser._sandbox.reset();
});

it('should get browser object', () => {
assert.isObject(browser, 'browser');
});

describe('create folder map', () => {
const func = mjs.createFolderMap;
beforeEach(() => {
Expand Down Expand Up @@ -96,7 +92,7 @@ describe('bookmark', () => {
type: 'folder'
};
await func(tree);
assert.isTrue(folderMap.has('foo'), 'key');
assert.strictEqual(folderMap.has('foo'), true, 'key');
});

it('should get map', async () => {
Expand Down Expand Up @@ -129,16 +125,16 @@ describe('bookmark', () => {
};
await func(tree);
assert.strictEqual(folderMap.size, 3, 'size');
assert.isTrue(folderMap.has('foo'), 'key');
assert.strictEqual(folderMap.has('foo'), true, 'key');
assert.deepEqual(Array.from(folderMap.get('foo').children), [
'bar',
'baz'
], 'set');
assert.isTrue(folderMap.has('bar'), 'key');
assert.strictEqual(folderMap.has('bar'), true, 'key');
assert.deepEqual(Array.from(folderMap.get('bar').children), [], 'set');
assert.isTrue(folderMap.has('baz'), 'key');
assert.isFalse(folderMap.has('qux'), 'key');
assert.isFalse(folderMap.has('quux'), 'key');
assert.strictEqual(folderMap.has('baz'), true, 'key');
assert.strictEqual(folderMap.has('qux'), false, 'key');
assert.strictEqual(folderMap.has('quux'), false, 'key');
});

it('should get map', async () => {
Expand Down Expand Up @@ -171,18 +167,18 @@ describe('bookmark', () => {
};
await func(tree, true);
assert.strictEqual(folderMap.size, 4, 'size');
assert.isTrue(folderMap.has('foo'), 'key');
assert.strictEqual(folderMap.has('foo'), true, 'key');
assert.deepEqual(Array.from(folderMap.get('foo').children), [
'bar',
'baz'
], 'set');
assert.isTrue(folderMap.has('bar'), 'key');
assert.strictEqual(folderMap.has('bar'), true, 'key');
assert.deepEqual(Array.from(folderMap.get('bar').children), [
'quux'
], 'set');
assert.isTrue(folderMap.has('baz'), 'key');
assert.isFalse(folderMap.has('qux'), 'key');
assert.isTrue(folderMap.has('quux'), 'key');
assert.strictEqual(folderMap.has('baz'), true, 'key');
assert.strictEqual(folderMap.has('qux'), false, 'key');
assert.strictEqual(folderMap.has('quux'), true, 'key');
});
});

Expand Down Expand Up @@ -225,18 +221,18 @@ describe('bookmark', () => {
type: 'folder'
}]);
const res = await func();
assert.instanceOf(res, Map, 'map');
assert.strictEqual(res instanceof Map, true, 'map');
assert.strictEqual(res.size, 3, 'size');
assert.isTrue(res.has('foo'), 'key');
assert.strictEqual(res.has('foo'), true, 'key');
assert.deepEqual(Array.from(res.get('foo').children), [
'bar',
'baz'
], 'set');
assert.isTrue(res.has('bar'), 'key');
assert.strictEqual(res.has('bar'), true, 'key');
assert.deepEqual(Array.from(res.get('bar').children), [], 'set');
assert.isTrue(res.has('baz'), 'key');
assert.isFalse(res.has('qux'), 'key');
assert.isFalse(res.has('quux'), 'key');
assert.strictEqual(res.has('baz'), true, 'key');
assert.strictEqual(res.has('qux'), false, 'key');
assert.strictEqual(res.has('quux'), false, 'key');
});

it('should get map', async () => {
Expand Down Expand Up @@ -267,18 +263,18 @@ describe('bookmark', () => {
type: 'folder'
}]);
const res = await func(true);
assert.instanceOf(res, Map, 'map');
assert.strictEqual(res instanceof Map, true, 'map');
assert.strictEqual(res.size, 4, 'size');
assert.isTrue(res.has('foo'), 'key');
assert.strictEqual(res.has('foo'), true, 'key');
assert.deepEqual(Array.from(res.get('foo').children), [
'bar',
'baz'
], 'set');
assert.isTrue(res.has('bar'), 'key');
assert.strictEqual(res.has('bar'), true, 'key');
assert.deepEqual(Array.from(res.get('bar').children), ['quux'], 'set');
assert.isTrue(res.has('baz'), 'key');
assert.isFalse(res.has('qux'), 'key');
assert.isTrue(res.has('quux'), 'key');
assert.strictEqual(res.has('baz'), true, 'key');
assert.strictEqual(res.has('qux'), false, 'key');
assert.strictEqual(res.has('quux'), true, 'key');
});
});

Expand All @@ -296,7 +292,7 @@ describe('bookmark', () => {
it('should get null', async () => {
browser.storage.local.get.withArgs(BOOKMARK_LOCATION).resolves(undefined);
const res = await func();
assert.isNull(res, 'result');
assert.strictEqual(res, null, 'result');
});

it('should get null', async () => {
Expand All @@ -306,7 +302,7 @@ describe('bookmark', () => {
}
});
const res = await func();
assert.isNull(res, 'result');
assert.strictEqual(res, null, 'result');
});

it('should get null', async () => {
Expand All @@ -324,7 +320,7 @@ describe('bookmark', () => {
const res = await func();
stub.restore();
assert.strictEqual(msg, 'error', 'log');
assert.isNull(res, 'result');
assert.strictEqual(res, null, 'result');
});

it('should get null', async () => {
Expand All @@ -337,7 +333,7 @@ describe('bookmark', () => {
foo: 'bar'
}]);
const res = await func();
assert.isNull(res, 'result');
assert.strictEqual(res, null, 'result');
});

it('should get result', async () => {
Expand Down
Loading

0 comments on commit 18010b4

Please sign in to comment.