diff --git a/__mocks__/uuid.js b/__mocks__/uuid.js
new file mode 100644
index 0000000..8b6c1be
--- /dev/null
+++ b/__mocks__/uuid.js
@@ -0,0 +1,5 @@
+module.exports = {
+ v4: function () {
+ return 'xxxx-xxxx'
+ }
+}
\ No newline at end of file
diff --git a/__tests__/transpiler.spec.js b/__tests__/transpiler.spec.js
new file mode 100644
index 0000000..28c8393
--- /dev/null
+++ b/__tests__/transpiler.spec.js
@@ -0,0 +1,71 @@
+var superviews = require('../index')
+
+function addWrapper (content) {
+ return ';(function () {' + '\n' + content + '\n' + '})()' + '\n'
+}
+
+describe('template', function () {
+ describe('with static content', function () {
+ it('should transpile simple element', function () {
+ var expected = (
+`var __target
+
+return function description (data) {
+elementOpen("div")
+elementClose("div")
+}`)
+ var output = superviews('
')
+ expect(output).toEqual(addWrapper(expected))
+ })
+
+ it('should transpile simple element with attributes', function () {
+ var expected = (
+`var hoisted1 = ["class", "header", "id", "title"]
+var __target
+
+return function description (data) {
+elementOpen("h1", "xxxx-xxxx", hoisted1)
+elementClose("h1")
+}`)
+
+ var output = superviews('')
+ expect(output).toEqual(addWrapper(expected))
+ })
+
+ it('should transpile void element', function () {
+ var expected = (
+`var __target
+
+return function description (data) {
+elementOpen("br")
+elementClose("br")
+}`)
+ var output = superviews('
')
+ expect(output).toEqual(addWrapper(expected))
+ })
+
+ it('should transpile single line text', function () {
+ var expected = (
+`var __target
+
+return function description (data) {
+text("my text")
+}`)
+ var output = superviews('my text')
+ expect(output).toEqual(addWrapper(expected))
+ })
+
+ it('should transpile multi line text', function () {
+ var expected = (
+`var __target
+
+return function description (data) {
+text("my very \\
+ long \\
+ text")
+}`)
+ var output = superviews('my very \n long \n text')
+ expect(output).toEqual(addWrapper(expected))
+ })
+ })
+})
diff --git a/package.json b/package.json
index 5e8acd6..a439093 100644
--- a/package.json
+++ b/package.json
@@ -12,7 +12,9 @@
"build:playground": "browserify -d examples/playground/playground.js > examples/playground/playground.bundle.js",
"build:customelements": "browserify examples/client/x-todos/index.js -t [superviewify --args 'el state'] -d -o examples/client/x-todos/bundle.js",
"build:examples": "browserify examples/client/x-widget/index.js -t [superviewify --args 'el state ctrl'] -d -o examples/client/x-widget/bundle.js",
- "build:readme": "cat test/readme.html | ./bin/cmd.js > test/readme.js"
+ "build:readme": "cat test/readme.html | ./bin/cmd.js > test/readme.js",
+ "test": "jest",
+ "test:watch": "jest --watch"
},
"repository": {
"type": "git",
@@ -34,6 +36,7 @@
"devDependencies": {
"brace": "0.9.0",
"browserify": "13.1.1",
+ "jest": "^20.0.4",
"standard": "8.5.0",
"superviewify": "3.0.0"
},