From eb59f7f694f046aceee14fe8ad1e14085b1e961e Mon Sep 17 00:00:00 2001 From: Mimi <1119186082@qq.com> Date: Tue, 4 May 2021 23:38:16 +0800 Subject: [PATCH] Improve test coverage --- .github/workflows/linter.yml | 3 +-- layout/_partials/footer.njk | 2 +- package.json | 2 +- scripts/helpers/next-url.js | 4 ---- test/helpers/next-url.js | 6 ++++++ 5 files changed, 9 insertions(+), 8 deletions(-) diff --git a/.github/workflows/linter.yml b/.github/workflows/linter.yml index c197b62..876c226 100644 --- a/.github/workflows/linter.yml +++ b/.github/workflows/linter.yml @@ -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 diff --git a/layout/_partials/footer.njk b/layout/_partials/footer.njk index c4534ab..94a85f0 100644 --- a/layout/_partials/footer.njk +++ b/layout/_partials/footer.njk @@ -77,7 +77,7 @@ {%- if theme.footer.powered %}
{%- 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)) }}
{%- endif %} diff --git a/package.json b/package.json index 013fe0f..a8bb877 100644 --- a/package.json +++ b/package.json @@ -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": [ diff --git a/scripts/helpers/next-url.js b/scripts/helpers/next-url.js index 240459a..5f06921 100644 --- a/scripts/helpers/next-url.js +++ b/scripts/helpers/next-url.js @@ -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; diff --git a/test/helpers/next-url.js b/test/helpers/next-url.js index a9fef70..20c4088 100644 --- a/test/helpers/next-url.js +++ b/test/helpers/next-url.js @@ -37,4 +37,10 @@ describe('next-url', () => { const encoded = btoa('https://theme-next.js.org'); nextUrl('https://theme-next.js.org', 'Text').should.eql(`Text`); }); + + 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(`Text`); + }); });