-
Notifications
You must be signed in to change notification settings - Fork 19
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
Showing
2 changed files
with
32 additions
and
5 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
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 |
---|---|---|
@@ -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() | ||
}) |