Skip to content

Commit

Permalink
test: improve coverage (#129)
Browse files Browse the repository at this point in the history
  • Loading branch information
D-Sketon authored Sep 22, 2023
1 parent 4640d56 commit b8e4365
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@
"eslint": "^8.6.0",
"eslint-config-hexo": "^5.0.0",
"mocha": "^10.2.0",
"nyc": "^15.1.0"
"nyc": "^15.1.0",
"sinon": "^15.2.0"
},
"dependencies": {
"hexo-fs": "^4.1.1",
Expand Down
31 changes: 31 additions & 0 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,16 @@ require('chai').should(); // eslint-disable-line
const pathFn = require('path');
const { spawn } = require('hexo-util');
const fs = require('hexo-fs');
const { stub, assert: sinonAssert } = require('sinon');
const { underline } = require('picocolors');
const Promise = require('bluebird');

const assetDir = pathFn.join(__dirname, '../assets');

describe('Heroku deployer', () => {
const baseDir = pathFn.join(__dirname, 'deployer_test');
const publicDir = pathFn.join(baseDir, 'public');
const deployDir = pathFn.join(baseDir, '.deploy_heroku');
const fakeRemote = pathFn.join(baseDir, 'remote');
const validateDir = pathFn.join(baseDir, 'validate');

Expand Down Expand Up @@ -95,4 +98,32 @@ describe('Heroku deployer', () => {
content.should.eql('custom message');
});
});

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: heroku\n';
help += ' repo: <repository url>\n';
help += ' message: [message]\n\n';
help += 'For more help, you can check the docs: ' + underline('http://hexo.io/docs/deployment.html');
sinonAssert.calledWithMatch(logStub, help);
logStub.restore();
});

it('exist deployDir', () => {
return fs.mkdirs(deployDir).then(() => {
return deployer({
repo: fakeRemote,
silent: true
});
}).then(() => {
return validate();
});
});
});

0 comments on commit b8e4365

Please sign in to comment.