/
meta_generator.js
35 lines (28 loc) · 1.02 KB
/
meta_generator.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
'use strict';
describe('Meta Generator', () => {
const Hexo = require('../../../lib/hexo');
const hexo = new Hexo();
const metaGenerator = require('../../../lib/plugins/filter/after_render/meta_generator').bind(hexo);
const cheerio = require('cheerio');
it('default', () => {
const content = '<head><link></head>';
const result = metaGenerator(content);
const $ = cheerio.load(result);
$('meta[name="generator"]').length.should.eql(1);
});
it('empty <head>', () => {
const content = '<head></head>';
const result = metaGenerator(content);
// meta generator should not be prepended if <head> tag is empty
// see https://github.com/hexojs/hexo/pull/3315
const resultType = typeof result;
resultType.should.eql('undefined');
});
it('disable meta_generator', () => {
const content = '<head><link></head>';
hexo.config.meta_generator = false;
const result = metaGenerator(content);
const resultType = typeof result;
resultType.should.eql('undefined');
});
});