Skip to content

Commit

Permalink
test: Add meta_generator
Browse files Browse the repository at this point in the history
  • Loading branch information
weyusi committed Oct 28, 2018
1 parent 0853115 commit 11c85de
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
1 change: 1 addition & 0 deletions test/scripts/filters/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ describe('Filters', () => {
require('./excerpt');
require('./external_link');
require('./i18n_locals');
require('./meta_generator');
require('./new_post_path');
require('./post_permalink');
require('./render_post');
Expand Down
36 changes: 36 additions & 0 deletions test/scripts/filters/meta_generator.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
'use strict';

const should = require('chai').should(); // eslint-disable-line

describe('Meta Generator', function() {
const Hexo = require('../../../lib/hexo');
const hexo = new Hexo();
const metaGenerator = require('../../../lib/plugins/filter/meta_generator').bind(hexo);
const cheerio = require('cheerio');

it('default', function() {
let content = `<head><link></head>`;

let data = {
content: content
};

metaGenerator(data);
const $ = cheerio.load(data);
$('meta[name="generator"]').length.should.eql(1);
});

it('empty <head>', function() {
let content = `<head></head>`;

let data = {
content: content
};

metaGenerator(data);
const $ = cheerio.load(data);
// meta generator should not be prepended if <head> tag is empty
// see https://github.com/hexojs/hexo/pull/3315
$('meta[name="generator"]').length.should.eql(0);
});
});

0 comments on commit 11c85de

Please sign in to comment.