/
test.js
68 lines (58 loc) · 2.72 KB
/
test.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
var assert = require("assert");
var moist = require("../moist.js");
describe("Moist", function() {
describe("#html(obj)", function() {
it("should generate an empty div", function() {
assert.equal('<div></div>', moist.html({div: []}));
});
it("should generate a div with class", function() {
var object = {div: [], _class: "content"},
expected = '<div class="content"></div>',
actual = moist.html(object);
assert.equal(actual, expected);
});
it("should generate a div with class and content", function() {
var object = {div: ["bobbins"], _class: "content"},
expected = '<div class="content">bobbins</div>',
actual = moist.html(object);
assert.equal(actual, expected);
});
it("should generate a div with class and nested content", function() {
var object = {div: [{h1: ["bobbins"]}], _class: "content"},
expected = '<div class="content"><h1>bobbins</h1></div>',
actual = moist.html(object);
assert.equal(actual, expected);
});
it("should generate a div with class and nested contents", function() {
var object = {div: [{h1: ["bobbins"]}, {p: ["nonsense"]}], _class: "content"},
expected = '<div class="content"><h1>bobbins</h1><p>nonsense</p></div>',
actual = moist.html(object);
assert.equal(actual, expected);
});
it("should generate two divs from an array", function() {
var object = [{div:[], _class: "span3"},{div: [], _class: "span9"}],
expected = '<div class="span3"></div><div class="span9"></div>',
actual = moist.html(object);
assert.equal(actual, expected);
});
it("should not generate a closing tag for img", function() {
var object = {img: [], src: "foo.png"},
expected = '<img src="foo.png">',
actual = moist.html(object);
assert.equal(actual, expected);
});
it("should concatenate variables", function() {
var name = "Marvin",
object = {div: ["Hello ", name, "!"]},
expected = '<div>Hello Marvin!</div>',
actual = moist.html(object);
assert.equal(actual, expected);
});
it("should change underscores to hyphens", function() {
var object = {div: [], ng_view: null},
expected = '<div ng-view></div>',
actual = moist.html(object);
assert.equal(actual, expected);
});
});
});