Skip to content
This repository has been archived by the owner on Dec 7, 2018. It is now read-only.

Commit

Permalink
test: Add html template tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergey Tatarintsev committed Nov 17, 2016
1 parent 80e2c4a commit 0d27769
Showing 1 changed file with 63 additions and 0 deletions.
63 changes: 63 additions & 0 deletions test/html-template.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
'use strict';

const htmlTemplate = require('../lib/html-template');
const jsdom = require('jsdom');
const assert = require('chai').assert;
const _ = require('lodash');

describe('html template', () => {
function renderTemplateAsDom(templateData) {
templateData = templateData || {};
_.defaults(templateData, {
name: '',
jsList: [],
cssList: []
});
return jsdom.jsdom(htmlTemplate(templateData));
}

it('should have a test name as a title', () => {
const document = renderTemplateAsDom({
title: 'some title'
});

assert.equal(document.title, 'some title');
});


it('should have a mount point', () => {
const document = renderTemplateAsDom();

assert.isOk(
document.querySelector('[data-gemini-react]'),
'Expected to have element with data-gemini-react attribute'
);
});

it('should include js from js list', () => {
const path = '/some/file.js';

const document = renderTemplateAsDom({
jsList: [path]
});

assert.isOk(
document.querySelector(`script[src='${path}']`),
'Expected to render script tag'
);
});


it('should include css from css list', () => {
const path = '/some/file.css';

const document = renderTemplateAsDom({
cssList: [path]
});

assert.isOk(
document.querySelector(`link[rel=stylesheet][href='${path}']`),
'Expected to render link[rel=stylesheet] tag'
);
});
});

0 comments on commit 0d27769

Please sign in to comment.