Skip to content

Commit

Permalink
Merge 5f11323 into 7520113
Browse files Browse the repository at this point in the history
  • Loading branch information
SukkaW committed Jul 6, 2020
2 parents 7520113 + 5f11323 commit 1159152
Show file tree
Hide file tree
Showing 12 changed files with 90 additions and 90 deletions.
32 changes: 16 additions & 16 deletions test/scripts/box/box.js
Expand Up @@ -4,7 +4,7 @@ const { join, sep } = require('path');
const { appendFile, mkdir, mkdirs, rename, rmdir, stat, unlink, writeFile } = require('hexo-fs');
const Promise = require('bluebird');
const { hash, Pattern } = require('hexo-util');
const { spy, match } = require('sinon');
const { spy, match, assert: sinonAssert } = require('sinon');

describe('Box', () => {
const Hexo = require('../../../lib/hexo');
Expand Down Expand Up @@ -110,7 +110,7 @@ describe('Box', () => {
await writeFile(path, 'a');
await box.process();

processor.calledWithMatch({ type: 'create', path: name }).should.be.true;
sinonAssert.calledWithMatch(processor, { type: 'create', path: name });

await rmdir(box.base);
});
Expand All @@ -134,7 +134,7 @@ describe('Box', () => {
]);
await box.process();

processor.calledWithMatch({ type: 'update', path: name }).should.be.true;
sinonAssert.calledWithMatch(processor, { type: 'update', path: name });

await rmdir(box.base);
});
Expand All @@ -157,7 +157,7 @@ describe('Box', () => {
});
await box.process();

processor.calledWithMatch({ type: 'skip', path: name }).should.be.true;
sinonAssert.calledWithMatch(processor, { type: 'skip', path: name });

await rmdir(box.base);
});
Expand All @@ -180,7 +180,7 @@ describe('Box', () => {
});
await box.process();

processor.calledWithMatch({ type: 'skip', path: name }).should.be.true;
sinonAssert.calledWithMatch(processor, { type: 'skip', path: name });

await rmdir(box.base);
});
Expand All @@ -203,7 +203,7 @@ describe('Box', () => {
});
await box.process();

processor.calledWithMatch({ type: 'skip', path: name }).should.be.true;
sinonAssert.calledWithMatch(processor, { type: 'skip', path: name });

await rmdir(box.base);
});
Expand All @@ -223,7 +223,7 @@ describe('Box', () => {
]);
await box.process();

processor.calledWith(match.has('type', 'delete')).should.be.true;
sinonAssert.calledWith(processor, match.has('type', 'delete'));
processor.calledOnce.should.be.true;

await rmdir(box.base);
Expand All @@ -240,7 +240,7 @@ describe('Box', () => {
await writeFile(path, 'a');
await box.process();

processor.calledWith(match.has('params', match.has('id', '123456'))).should.be.true;
sinonAssert.calledWith(processor, match.has('params', match.has('id', '123456')));
processor.calledOnce.should.be.true;

await rmdir(box.base);
Expand Down Expand Up @@ -314,12 +314,12 @@ describe('Box', () => {
box.isWatching().should.be.true;
await Promise.delay(500);

processor.firstCall.calledWithMatch({
sinonAssert.calledWithMatch(processor.firstCall, {
source: src,
path: path,
type: 'create',
params: {}
}).should.be.true;
});

box.unwatch();
await rmdir(box.base);
Expand All @@ -343,12 +343,12 @@ describe('Box', () => {
await appendFile(src, 'b');
await Promise.delay(500);

processor.lastCall.calledWithMatch({
sinonAssert.calledWithMatch(processor.lastCall, {
source: src,
path: path,
type: 'update',
params: {}
}).should.be.true;
});

box.unwatch();
await rmdir(box.base);
Expand All @@ -372,12 +372,12 @@ describe('Box', () => {
await unlink(src);
await Promise.delay(500);

processor.lastCall.calledWithMatch({
sinonAssert.calledWithMatch(processor.lastCall, {
source: src,
path: path,
type: 'delete',
params: {}
}).should.be.true;
});

box.unwatch();
await rmdir(box.base);
Expand Down Expand Up @@ -632,8 +632,8 @@ describe('Box', () => {
await writeFile(join(box.base, 'a.txt'), 'a');
await box.process();

beforeSpy.calledWithMatch({ type: 'create', path: 'a.txt' }).should.be.true;
afterSpy.calledWithMatch({ type: 'create', path: 'a.txt' }).should.be.true;
sinonAssert.calledWithMatch(beforeSpy, { type: 'create', path: 'a.txt' });
sinonAssert.calledWithMatch(afterSpy, { type: 'create', path: 'a.txt' });
beforeSpy.calledOnce.should.be.true;
afterSpy.calledOnce.should.be.true;

Expand Down
8 changes: 4 additions & 4 deletions test/scripts/console/config.js
Expand Up @@ -3,7 +3,7 @@
const { mkdirs, readFile, rmdir, unlink, writeFile } = require('hexo-fs');
const { join } = require('path');
const { load } = require('js-yaml');
const { stub } = require('sinon');
const { stub, assert: sinonAssert } = require('sinon');

describe('config', () => {
const Hexo = require('../../../lib/hexo');
Expand All @@ -28,7 +28,7 @@ describe('config', () => {
logStub.restore();
}

logStub.calledWith(hexo.config).should.be.true;
sinonAssert.calledWith(logStub, hexo.config);
});

it('read config', async () => {
Expand All @@ -40,7 +40,7 @@ describe('config', () => {
logStub.restore();
}

logStub.calledWith(hexo.config.title).should.be.true;
sinonAssert.calledWith(logStub, hexo.config.title);
});

it('read nested config', async () => {
Expand All @@ -52,7 +52,7 @@ describe('config', () => {
};

await config({_: ['server.port']});
logStub.calledWith(hexo.config.server.port).should.be.true;
sinonAssert.calledWith(logStub, hexo.config.server.port);
} finally {
delete hexo.config.server;
logStub.restore();
Expand Down
19 changes: 10 additions & 9 deletions test/scripts/console/deploy.js
Expand Up @@ -2,7 +2,7 @@

const { exists, mkdirs, readFile, rmdir, writeFile } = require('hexo-fs');
const { join } = require('path');
const { spy, stub } = require('sinon');
const { spy, stub, assert: sinonAssert } = require('sinon');

describe('deploy', () => {
const Hexo = require('../../../lib/hexo');
Expand Down Expand Up @@ -32,9 +32,10 @@ describe('deploy', () => {
logStub.restore();
}

logStub.calledWithMatch(
sinonAssert.calledWithMatch(
logStub,
'You should configure deployment settings in _config.yml first!'
).should.be.true;
);
});

it('single deploy setting', async () => {
Expand All @@ -56,11 +57,11 @@ describe('deploy', () => {
beforeListener.calledOnce.should.be.true;
afterListener.calledOnce.should.be.true;

deployer.calledWith({
sinonAssert.calledWith(deployer, {
type: 'foo',
foo: 'foo',
bar: 'bar'
}).should.be.true;
});
});

it('multiple deploy setting', async () => {
Expand All @@ -79,16 +80,16 @@ describe('deploy', () => {
deployer1.calledOnce.should.be.true;
deployer2.calledOnce.should.be.true;

deployer1.calledWith({
sinonAssert.calledWith(deployer1, {
type: 'foo',
foo: 'foo',
test: true
}).should.be.true;
deployer2.calledWith({
});
sinonAssert.calledWith(deployer2, {
type: 'bar',
bar: 'bar',
test: true
}).should.be.true;
});
});

// it('deployer not found'); missing-unit-test
Expand Down
16 changes: 8 additions & 8 deletions test/scripts/console/list_categories.js
@@ -1,7 +1,7 @@
'use strict';

const Promise = require('bluebird');
const { stub } = require('sinon');
const { stub, assert: sinonAssert } = require('sinon');

describe('Console list', () => {
const Hexo = require('../../../lib/hexo');
Expand All @@ -20,9 +20,9 @@ describe('Console list', () => {

it('no categories', () => {
listCategories();
logStub.calledWithMatch('Name').should.be.true;
logStub.calledWithMatch('Posts').should.be.true;
logStub.calledWithMatch('No categories.').should.be.true;
sinonAssert.calledWithMatch(logStub, 'Name');
sinonAssert.calledWithMatch(logStub, 'Posts');
sinonAssert.calledWithMatch(logStub, 'No categories.');
});

it('categories', async () => {
Expand All @@ -41,9 +41,9 @@ describe('Console list', () => {
], (tags, i) => output[i].setCategories(tags));
await hexo.locals.invalidate();
listCategories();
logStub.calledWithMatch('Name').should.be.true;
logStub.calledWithMatch('Posts').should.be.true;
logStub.calledWithMatch('baz').should.be.true;
logStub.calledWithMatch('foo').should.be.true;
sinonAssert.calledWithMatch(logStub, 'Name');
sinonAssert.calledWithMatch(logStub, 'Posts');
sinonAssert.calledWithMatch(logStub, 'baz');
sinonAssert.calledWithMatch(logStub, 'foo');
});
});
20 changes: 10 additions & 10 deletions test/scripts/console/list_page.js
@@ -1,6 +1,6 @@
'use strict';

const { stub } = require('sinon');
const { stub, assert: sinonAssert } = require('sinon');

describe('Console list', () => {
const Hexo = require('../../../lib/hexo');
Expand All @@ -20,10 +20,10 @@ describe('Console list', () => {

it('no page', () => {
listPages();
logStub.calledWithMatch('Date').should.be.true;
logStub.calledWithMatch('Title').should.be.true;
logStub.calledWithMatch('Path').should.be.true;
logStub.calledWithMatch('No pages.').should.be.true;
sinonAssert.calledWithMatch(logStub, 'Date');
sinonAssert.calledWithMatch(logStub, 'Title');
sinonAssert.calledWithMatch(logStub, 'Path');
sinonAssert.calledWithMatch(logStub, 'No pages.');
});

it('page', async () => {
Expand All @@ -33,10 +33,10 @@ describe('Console list', () => {
path: 'bar'
});
listPages();
logStub.calledWithMatch('Date').should.be.true;
logStub.calledWithMatch('Title').should.be.true;
logStub.calledWithMatch('Path').should.be.true;
logStub.calledWithMatch('Hello World').should.be.true;
logStub.calledWithMatch('foo').should.be.true;
sinonAssert.calledWithMatch(logStub, 'Date');
sinonAssert.calledWithMatch(logStub, 'Title');
sinonAssert.calledWithMatch(logStub, 'Path');
sinonAssert.calledWithMatch(logStub, 'Hello World');
sinonAssert.calledWithMatch(logStub, 'foo');
});
});
35 changes: 17 additions & 18 deletions test/scripts/console/list_post.js
@@ -1,6 +1,6 @@
'use strict';

const { stub } = require('sinon');
const { stub, assert: sinonAssert } = require('sinon');

describe('Console list', () => {
const Hexo = require('../../../lib/hexo');
Expand All @@ -19,12 +19,12 @@ describe('Console list', () => {

it('no post', () => {
listPosts();
logStub.calledWithMatch('Date').should.be.true;
logStub.calledWithMatch('Title').should.be.true;
logStub.calledWithMatch('Path').should.be.true;
logStub.calledWithMatch('Category').should.be.true;
logStub.calledWithMatch('Tags').should.be.true;
logStub.calledWithMatch('No posts.').should.be.true;
sinonAssert.calledWithMatch(logStub, 'Date');
sinonAssert.calledWithMatch(logStub, 'Title');
sinonAssert.calledWithMatch(logStub, 'Path');
sinonAssert.calledWithMatch(logStub, 'Category');
sinonAssert.calledWithMatch(logStub, 'Tags');
sinonAssert.calledWithMatch(logStub, 'No posts.');
});

it('post', async () => {
Expand All @@ -39,16 +39,15 @@ describe('Console list', () => {
await hexo.locals.invalidate();

listPosts();
logStub.calledWithMatch('Date').should.be.true;
logStub.calledWithMatch('Title').should.be.true;
logStub.calledWithMatch('Path').should.be.true;
logStub.calledWithMatch('Category').should.be.true;
logStub.calledWithMatch('Tags').should.be.true;
posts.forEach(post => {
logStub.calledWithMatch(post.source).should.be.true;
logStub.calledWithMatch(post.source).should.be.true;
logStub.calledWithMatch(post.slug).should.be.true;
logStub.calledWithMatch(post.title).should.be.true;
});
sinonAssert.calledWithMatch(logStub, 'Date');
sinonAssert.calledWithMatch(logStub, 'Title');
sinonAssert.calledWithMatch(logStub, 'Path');
sinonAssert.calledWithMatch(logStub, 'Category');
sinonAssert.calledWithMatch(logStub, 'Tags');
for (let i = 0; i < posts.length; i++) {
sinonAssert.calledWithMatch(logStub, posts[i].source);
sinonAssert.calledWithMatch(logStub, posts[i].slug);
sinonAssert.calledWithMatch(logStub, posts[i].title);
}
});
});
24 changes: 12 additions & 12 deletions test/scripts/console/list_tags.js
@@ -1,7 +1,7 @@
'use strict';

const Promise = require('bluebird');
const { stub } = require('sinon');
const { stub, assert: sinonAssert } = require('sinon');

describe('Console list', () => {
const Hexo = require('../../../lib/hexo');
Expand All @@ -22,10 +22,10 @@ describe('Console list', () => {

it('no tags', () => {
listTags();
logStub.calledWithMatch('Name').should.be.true;
logStub.calledWithMatch('Posts').should.be.true;
logStub.calledWithMatch('Path').should.be.true;
logStub.calledWithMatch('No tags.').should.be.true;
sinonAssert.calledWithMatch(logStub, 'Name');
sinonAssert.calledWithMatch(logStub, 'Posts');
sinonAssert.calledWithMatch(logStub, 'Path');
sinonAssert.calledWithMatch(logStub, 'No tags.');
});

it('tags', async () => {
Expand All @@ -45,12 +45,12 @@ describe('Console list', () => {
await hexo.locals.invalidate();

listTags();
logStub.calledWithMatch('Name').should.be.true;
logStub.calledWithMatch('Posts').should.be.true;
logStub.calledWithMatch('Path').should.be.true;
logStub.calledWithMatch('baz').should.be.true;
logStub.calledWithMatch('foo').should.be.true;
logStub.calledWithMatch('tags/baz').should.be.true;
logStub.calledWithMatch('tags/foo').should.be.true;
sinonAssert.calledWithMatch(logStub, 'Name');
sinonAssert.calledWithMatch(logStub, 'Posts');
sinonAssert.calledWithMatch(logStub, 'Path');
sinonAssert.calledWithMatch(logStub, 'baz');
sinonAssert.calledWithMatch(logStub, 'foo');
sinonAssert.calledWithMatch(logStub, 'tags/baz');
sinonAssert.calledWithMatch(logStub, 'tags/foo');
});
});

0 comments on commit 1159152

Please sign in to comment.