Skip to content

Commit

Permalink
add tests for cli and bundle mode
Browse files Browse the repository at this point in the history
  • Loading branch information
ananavati committed Oct 11, 2016
1 parent 2a27cf2 commit 090ba1d
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 5 deletions.
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,11 @@
"btoa": "^1.1.1",
"clean-css": "^2.1.6",
"domready": "^1.0.4",
"jsdom": "^9.6.0",
"marked": "^0.3.2",
"prettysize": "0.0.3",
"rework": "^0.20.2",
"shelljs": "^0.7.4",
"tap-spec": "^2.1.2",
"tape": "^3.0.3",
"uglify-js": "^2.4.15"
Expand Down
35 changes: 30 additions & 5 deletions test/bundle.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,36 @@
var bundle = require('../').bundle
var test = require('tape')
var fs = require('fs')
var jsdom = require("jsdom")
var shell = require('shelljs')

test('bundle', function(t) {
bundle([fs.readFileSync(__dirname + '/fixture/sample-stats.json', 'utf8')], function(err, res) {
t.notOk(err)
t.ok(res)
t.end()
test('bundle callback', function(t) {
bundle([fs.readFileSync(__dirname + '/fixture/sample-stats.json', 'utf8')], function(err, res) {
t.notOk(err, 'no error')
t.ok(res, 'index.html response okay')

jsdom.env(res, function(err, window) {
var div = window.document.createElement('div');
div.innerHTML = res;

t.equal(div.getElementsByClassName("chart").length, 1, 'svg chart div')
})

t.end()
})
})

test('bundle cli', function(t) {
shell.exec('./bin/electrify /fixture/sample-stats.json', function(code, stdout, stderr) {
t.notOk(stderr, 'no error')
t.ok(stdout, 'stdout index.html')
jsdom.env(stdout, function(err, window) {
var div = window.document.createElement('div');
div.innerHTML = stdout;

t.equal(div.getElementsByClassName("chart").length, 1, 'svg chart div')
})
})

t.end()
})

0 comments on commit 090ba1d

Please sign in to comment.