mirror of
https://github.com/wassname/template.git
synced 2026-07-15 11:27:10 +08:00
More actual tests
This commit is contained in:
@@ -10,7 +10,6 @@ import footer from "./components/footer";
|
||||
import citation from "./components/citation";
|
||||
import markdown from "./components/markdown";
|
||||
import code from "./components/code";
|
||||
import testData from "./test-data";
|
||||
|
||||
function render(dom, data) {
|
||||
data = data || {};
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
"author": "Shan Carter",
|
||||
"dependencies": {
|
||||
"bibtex-parse-js": "^0.0.23",
|
||||
"chai": "^3.5.0",
|
||||
"js-yaml": "^3.7.0",
|
||||
"jsdom": "^9.9.1",
|
||||
"marked": "^0.3.6",
|
||||
|
||||
+55
-9
@@ -1,13 +1,59 @@
|
||||
let assert = require("assert"),
|
||||
jsdom = require("jsdom").jsdom,
|
||||
// Test format: https://mochajs.org/#bdd
|
||||
// Assertion format: http://chaijs.com/api/bdd/
|
||||
|
||||
let expect = require('chai').expect,
|
||||
jsdom = require("jsdom"),
|
||||
distill = require("../dist/template.js");
|
||||
|
||||
describe("distill", () => {
|
||||
it("Should have a render function", () => {
|
||||
assert(distill.render);
|
||||
describe("Distill", function() {
|
||||
describe("render", function() {
|
||||
it("Should have a render function.", function() {
|
||||
expect(distill.render).to.be.an.instanceof(Function);
|
||||
});
|
||||
});
|
||||
//
|
||||
// html
|
||||
//
|
||||
describe("html", function() {
|
||||
it("Should have a html function.", function() {
|
||||
expect(distill.html).to.be.an.instanceof(Function);
|
||||
});
|
||||
it("Should add a language attribute to html element, if not present.", function() {
|
||||
var doc = jsdom.jsdom("");
|
||||
let before = jsdom.serializeDocument(doc);
|
||||
distill.html(doc, {});
|
||||
let after = jsdom.serializeDocument(doc);
|
||||
expect(after).to.match(new RegExp('<html lang="en">'));
|
||||
});
|
||||
it("Should not add a language attribute to html element, if already present.", function() {
|
||||
var doc = jsdom.jsdom('<html lang="ab">');
|
||||
let before = jsdom.serializeDocument(doc);
|
||||
distill.html(doc, {});
|
||||
let after = jsdom.serializeDocument(doc);
|
||||
expect(after).to.not.match(new RegExp('lang="en"'));
|
||||
});
|
||||
it("Should add a meta charset tag, if not present.", function() {
|
||||
var doc = jsdom.jsdom("");
|
||||
let before = jsdom.serializeDocument(doc);
|
||||
distill.html(doc, {});
|
||||
let after = jsdom.serializeDocument(doc);
|
||||
expect(after).to.match(new RegExp('<meta charset="utf-8">'));
|
||||
});
|
||||
it("Should add a meta viewport tag, if not present.", function() {
|
||||
var doc = jsdom.jsdom("");
|
||||
let before = jsdom.serializeDocument(doc);
|
||||
distill.html(doc, {});
|
||||
let after = jsdom.serializeDocument(doc);
|
||||
expect(after).to.match(new RegExp('<meta name="viewport" content="width=device-width, initial-scale=1">'));
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
// var doc = jsdom("<script>var shan = 'testing'</script>");
|
||||
// var window = doc.defaultView;
|
||||
// console.log(window.shan);
|
||||
//
|
||||
// styles
|
||||
//
|
||||
describe("styles", function() {
|
||||
it("Should have a styles function.", function() {
|
||||
expect(distill.styles).to.be.an.instanceof(Function);
|
||||
});
|
||||
})
|
||||
});
|
||||
|
||||
@@ -118,6 +118,10 @@ assert-plus@^1.0.0:
|
||||
version "1.0.0"
|
||||
resolved "https://registry.yarnpkg.com/assert-plus/-/assert-plus-1.0.0.tgz#f12e0f3c5d77b0b1cdd9146942e4e96c1e4dd525"
|
||||
|
||||
assertion-error@^1.0.1:
|
||||
version "1.0.2"
|
||||
resolved "https://registry.yarnpkg.com/assertion-error/-/assertion-error-1.0.2.tgz#13ca515d86206da0bac66e834dd397d87581094c"
|
||||
|
||||
async-each@^1.0.0:
|
||||
version "1.0.1"
|
||||
resolved "https://registry.yarnpkg.com/async-each/-/async-each-1.0.1.tgz#19d386a1d9edc6e7c1c85d388aedbcc56d33602d"
|
||||
@@ -230,6 +234,14 @@ center-align@^0.1.1:
|
||||
align-text "^0.1.3"
|
||||
lazy-cache "^1.0.3"
|
||||
|
||||
chai@^3.5.0:
|
||||
version "3.5.0"
|
||||
resolved "https://registry.yarnpkg.com/chai/-/chai-3.5.0.tgz#4d02637b067fe958bdbfdd3a40ec56fef7373247"
|
||||
dependencies:
|
||||
assertion-error "^1.0.1"
|
||||
deep-eql "^0.1.3"
|
||||
type-detect "^1.0.0"
|
||||
|
||||
chalk@^1.1.1, chalk@^1.1.3:
|
||||
version "1.1.3"
|
||||
resolved "https://registry.yarnpkg.com/chalk/-/chalk-1.1.3.tgz#a8115c55e4a702fe4d150abd3872822a7e09fc98"
|
||||
@@ -335,6 +347,12 @@ decamelize@^1.0.0:
|
||||
version "1.2.0"
|
||||
resolved "https://registry.yarnpkg.com/decamelize/-/decamelize-1.2.0.tgz#f6534d15148269b20352e7bee26f501f9a191290"
|
||||
|
||||
deep-eql@^0.1.3:
|
||||
version "0.1.3"
|
||||
resolved "https://registry.yarnpkg.com/deep-eql/-/deep-eql-0.1.3.tgz#ef558acab8de25206cd713906d74e56930eb69f2"
|
||||
dependencies:
|
||||
type-detect "0.1.1"
|
||||
|
||||
deep-extend@~0.4.0:
|
||||
version "0.4.1"
|
||||
resolved "https://registry.yarnpkg.com/deep-extend/-/deep-extend-0.4.1.tgz#efe4113d08085f4e6f9687759810f807469e2253"
|
||||
@@ -537,7 +555,7 @@ glob-parent@^2.0.0:
|
||||
dependencies:
|
||||
is-glob "^2.0.0"
|
||||
|
||||
glob@7.0.5:
|
||||
glob@7.0.5, glob@^7.0.5:
|
||||
version "7.0.5"
|
||||
resolved "https://registry.yarnpkg.com/glob/-/glob-7.0.5.tgz#b4202a69099bbb4d292a7c1b95b6682b67ebdc95"
|
||||
dependencies:
|
||||
@@ -548,17 +566,6 @@ glob@7.0.5:
|
||||
once "^1.3.0"
|
||||
path-is-absolute "^1.0.0"
|
||||
|
||||
glob@^7.0.5:
|
||||
version "7.1.1"
|
||||
resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.1.tgz#805211df04faaf1c63a3600306cdf5ade50b2ec8"
|
||||
dependencies:
|
||||
fs.realpath "^1.0.0"
|
||||
inflight "^1.0.4"
|
||||
inherits "2"
|
||||
minimatch "^3.0.2"
|
||||
once "^1.3.0"
|
||||
path-is-absolute "^1.0.0"
|
||||
|
||||
good-listener@^1.2.0:
|
||||
version "1.2.1"
|
||||
resolved "https://registry.yarnpkg.com/good-listener/-/good-listener-1.2.1.tgz#4c5b4681a3e8c91b00f1cb12d89a23b32473547b"
|
||||
@@ -1451,6 +1458,14 @@ type-check@~0.3.2:
|
||||
dependencies:
|
||||
prelude-ls "~1.1.2"
|
||||
|
||||
type-detect@0.1.1:
|
||||
version "0.1.1"
|
||||
resolved "https://registry.yarnpkg.com/type-detect/-/type-detect-0.1.1.tgz#0ba5ec2a885640e470ea4e8505971900dac58822"
|
||||
|
||||
type-detect@^1.0.0:
|
||||
version "1.0.0"
|
||||
resolved "https://registry.yarnpkg.com/type-detect/-/type-detect-1.0.0.tgz#762217cc06db258ec48908a1298e8b95121e8ea2"
|
||||
|
||||
uglify-js@^2.6.1:
|
||||
version "2.7.5"
|
||||
resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-2.7.5.tgz#4612c0c7baaee2ba7c487de4904ae122079f2ca8"
|
||||
|
||||
Reference in New Issue
Block a user