'use strict';
require('chai').should();
const Hexo = require('hexo');
const hexo = new Hexo();
function btoa(str) {
return Buffer.from(str).toString('base64');
}
describe('next-url', () => {
const nextUrl = require('../../scripts/helpers/next-url').bind(hexo);
before(() => {
hexo.config.url = 'https://example.com';
hexo.url_for = require('hexo/lib/plugins/helper/url_for').bind(hexo);
});
it('text', () => {
nextUrl('/child/', 'Text').should.eql('Text');
});
it('icon', () => {
nextUrl('/child/', '').should.eql('');
});
it('class', () => {
nextUrl('/child/', 'Text', { class: 'theme-link' }).should.eql('Text');
});
it('external', () => {
nextUrl('https://theme-next.js.org', 'Text').should.eql('Text');
});
it('exturl enabled', () => {
hexo.theme.exturl = true;
const encoded = btoa('https://theme-next.js.org');
nextUrl('https://theme-next.js.org', 'Text').should.eql(`Text`);
});
});