-
-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
merge(#4422): from sukkaw/test-coverage-2
- Loading branch information
Showing
11 changed files
with
117 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,43 @@ | ||
'use strict'; | ||
|
||
const { spy, assert: sinonAssert } = require('sinon'); | ||
const { spy, assert: sinonAssert, stub } = require('sinon'); | ||
|
||
describe('migrate', () => { | ||
const Hexo = require('../../../lib/hexo'); | ||
const hexo = new Hexo(__dirname, {silent: true}); | ||
const hexo = new Hexo(__dirname, { silent: true }); | ||
const migrate = require('../../../lib/plugins/console/migrate').bind(hexo); | ||
|
||
it('default', async () => { | ||
const migrator = spy(); | ||
|
||
hexo.extend.migrator.register('test', migrator); | ||
|
||
await migrate({_: ['test'], foo: 1, bar: 2}); | ||
await migrate({ _: ['test'], foo: 1, bar: 2 }); | ||
|
||
sinonAssert.calledWithMatch(migrator, { foo: 1, bar: 2 }); | ||
migrator.calledOnce.should.be.true; | ||
}); | ||
|
||
it('no args', async () => { | ||
const hexo = new Hexo(__dirname, { silent: true }); | ||
hexo.call = spy(); | ||
const migrate = require('../../../lib/plugins/console/migrate').bind(hexo); | ||
|
||
await migrate({ _: [] }); | ||
hexo.call.calledOnce.should.be.true; | ||
hexo.call.args[0][0].should.eql('help'); | ||
hexo.call.args[0][1]._[0].should.eql('migrate'); | ||
}); | ||
|
||
it('migrator not found', async () => { | ||
const logStub = stub(console, 'log'); | ||
|
||
await migrate({ _: ['foo'] }); | ||
|
||
logStub.calledOnce.should.be.true; | ||
logStub.args[0][0].should.contains('migrator plugin is not installed.'); | ||
logStub.args[0][0].should.contains('Installed migrator plugins:'); | ||
|
||
logStub.restore(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,12 @@ describe('mail_to', () => { | |
mailto('[email protected]').should.eql('<a href="mailto:[email protected]" title="[email protected]">[email protected]</a>'); | ||
}); | ||
|
||
it('path - array', () => { | ||
const emails = ['[email protected]', '[email protected]']; | ||
const emailsStr = '[email protected],[email protected]'; | ||
mailto(emails).should.eql(`<a href="mailto:${emailsStr}" title="${emailsStr}">${emailsStr}</a>`); | ||
}); | ||
|
||
it('text', () => { | ||
mailto('[email protected]', 'Email').should.eql('<a href="mailto:[email protected]" title="Email">Email</a>'); | ||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters