Skip to content

Commit

Permalink
test: improve coverage (#327)
Browse files Browse the repository at this point in the history
* test: improve coverage

* lint
  • Loading branch information
D-Sketon committed Aug 31, 2023
1 parent 21292ed commit fa7b8ea
Show file tree
Hide file tree
Showing 4 changed files with 277 additions and 2 deletions.
242 changes: 241 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@
"chai": "^4.3.7",
"eslint": "^8.33.0",
"eslint-config-hexo": "^5.0.0",
"mocha": "^10.2.0"
"mocha": "^10.2.0",
"sinon": "^15.2.0"
},
"dependencies": {
"bluebird": "^3.7.2",
Expand Down
21 changes: 21 additions & 0 deletions test/deployer.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ const should = require('chai').should(); // eslint-disable-line
const pathFn = require('path');
const util = require('hexo-util');
const fs = require('hexo-fs');
const { stub, assert: sinonAssert } = require('sinon');
const Promise = require('bluebird');
const spawn = util.spawn;
const { underline } = require('picocolors');

describe('deployer', () => {
const baseDir = pathFn.join(__dirname, 'deployer_test');
Expand Down Expand Up @@ -244,4 +246,23 @@ describe('deployer', () => {
});
});
});

it('without repo and repository', () => {
fs.mkdirSync(validateDir);
const logStub = stub(console, 'log');
process.env.HEXO_DEPLOYER_REPO = '';
deployer({});
let help = '';
help += 'You have to configure the deployment settings in _config.yml first!\n\n';
help += 'Example:\n';
help += ' deploy:\n';
help += ' type: git\n';
help += ' repo: <repository url>\n';
help += ' branch: [branch]\n';
help += ' message: [message]\n\n';
help += ' extend_dirs: [extend directory]\n\n';
help += 'For more help, you can check the docs: ' + underline('https://hexo.io/docs/deployment.html');
sinonAssert.calledWithMatch(logStub, help);
logStub.restore();
});
});

0 comments on commit fa7b8ea

Please sign in to comment.