This repository has been archived by the owner on Dec 7, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Sergey Tatarintsev
committed
Nov 17, 2016
1 parent
80e2c4a
commit 0d27769
Showing
1 changed file
with
63 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' | ||
); | ||
}); | ||
}); |