Improve test coverage

This commit is contained in:
Mimi 2021-05-04 23:38:16 +08:00
parent 54b32d7f4b
commit eb59f7f694
5 changed files with 9 additions and 8 deletions

View File

@ -12,9 +12,8 @@ jobs:
- name: Install Dependencies
run: npm install
- run: npm run eslint
- run: npm test
- name: Coverage
run: npm run test-cov
run: npx nyc --reporter=lcovonly npm test
env:
CI: true
- name: Coveralls

View File

@ -77,7 +77,7 @@
{%- if theme.footer.powered %}
<div class="powered-by">
{%- set next_site = 'https://theme-next.js.org' if theme.scheme === 'Gemini' else 'https://theme-next.js.org/' + theme.scheme | lower + '/' %}
{{- __('footer.powered', next_url('https://hexo.io', 'Hexo', {class: 'theme-link'}) + ' & ' + next_url(next_site, 'NexT.' + theme.scheme, {class: 'theme-link'})) }}
{{- __('footer.powered', next_url('https://hexo.io', 'Hexo') + ' & ' + next_url(next_site, 'NexT.' + theme.scheme)) }}
</div>
{%- endif %}

View File

@ -17,7 +17,7 @@
"prepare": "node .githooks/install.js",
"stylint": "stylint source/css/",
"test": "mocha test/index.js",
"test-cov": "nyc --reporter=lcovonly npm run test"
"test-cov": "nyc npm test"
},
"repository": "next-theme/hexo-theme-next",
"keywords": [

View File

@ -36,10 +36,6 @@ module.exports = function(path, text, options = {}) {
}
}
if (attrs.class && Array.isArray(attrs.class)) {
attrs.class = attrs.class.join(' ');
}
// If it's external link, rewrite attributes.
if (data.protocol && data.hostname !== siteHost) {
attrs.external = null;

View File

@ -37,4 +37,10 @@ describe('next-url', () => {
const encoded = btoa('https://theme-next.js.org');
nextUrl('https://theme-next.js.org', 'Text').should.eql(`<span class="exturl" data-url="${encoded}">Text</span>`);
});
it('class with exturl enabled', () => {
hexo.theme.exturl = true;
const encoded = btoa('https://theme-next.js.org');
nextUrl('https://theme-next.js.org', 'Text', { class: 'theme-link' }).should.eql(`<span class="exturl theme-link" data-url="${encoded}">Text</span>`);
});
});