Demo for query storing
Change-Id: I947bcac841992c3f6cfd01ab337c265b0d01cb70
diff --git a/node_modules/console-stream/test/index.js b/node_modules/console-stream/test/index.js
new file mode 100644
index 0000000..5f60123
--- /dev/null
+++ b/node_modules/console-stream/test/index.js
@@ -0,0 +1,83 @@
+var ConsoleStream = require("../index")
+var console = require("console")
+var test = require("tape")
+
+test("console stream", function (assert) {
+ var stream = ConsoleStream()
+
+ assert.ok(stream.write)
+ assert.ok(stream.end)
+ assert.ok(stream.destroy)
+
+ assert.end()
+})
+
+test("console stream destroy", function (assert) {
+ var stream = ConsoleStream()
+
+ stream.once("close", function () {
+ assert.ok(true)
+ assert.end()
+ })
+
+ stream.destroy()
+})
+
+test("console stream end", function (assert) {
+ var old = console.log
+ console.log = intercept
+
+ var closed = false
+ var stream = ConsoleStream()
+ var list = []
+
+ stream.once("close", function () {
+ closed = true
+
+ console.log = old
+
+ assert.deepEqual(list, ["foo"])
+ assert.equal(closed, true)
+
+ assert.end()
+ })
+
+ stream.end("foo")
+
+ function intercept(chunk) {
+ list.push(chunk)
+
+ // old.apply(this, arguments)
+ }
+})
+
+test("console stream write", function (assert) {
+ var old = console.log
+ console.log = intercept
+
+ var list = []
+ var stream = ConsoleStream()
+
+ stream.write("one")
+ stream.write("two")
+ stream.write("three")
+ stream.write("four\n")
+ stream.write("five\na")
+ stream.write("bar")
+ stream.end()
+
+ console.log = old
+
+ assert.deepEqual(list, [
+ "onetwothreefour"
+ , "five"
+ , "abar"
+ ])
+ assert.end()
+
+ function intercept(chunk) {
+ list.push(chunk)
+
+ // old.apply(this, arguments)
+ }
+})
diff --git a/node_modules/console-stream/test/static/index.html b/node_modules/console-stream/test/static/index.html
new file mode 100644
index 0000000..60f6ef8
--- /dev/null
+++ b/node_modules/console-stream/test/static/index.html
@@ -0,0 +1,11 @@
+<!doctype html>
+<html>
+<head>
+ <title>TAPE Example</title>
+ <script src="/testem.js"></script>
+ <script src="test-adapter.js"></script>
+ <script src="bundle.js"></script>
+</head>
+<body>
+</body>
+</html>
diff --git a/node_modules/console-stream/test/static/test-adapter.js b/node_modules/console-stream/test/static/test-adapter.js
new file mode 100644
index 0000000..8b4c12d
--- /dev/null
+++ b/node_modules/console-stream/test/static/test-adapter.js
@@ -0,0 +1,53 @@
+(function () {
+ var Testem = window.Testem
+ var regex = /^((?:not )?ok) (\d+) (.+)$/
+
+ Testem.useCustomAdapter(tapAdapter)
+
+ function tapAdapter(socket){
+ var results = {
+ failed: 0
+ , passed: 0
+ , total: 0
+ , tests: []
+ }
+
+ socket.emit('tests-start')
+
+ Testem.handleConsoleMessage = function(msg){
+ var m = msg.match(regex)
+ if (m) {
+ var passed = m[1] === 'ok'
+ var test = {
+ passed: passed ? 1 : 0,
+ failed: passed ? 0 : 1,
+ total: 1,
+ id: m[2],
+ name: m[3],
+ items: []
+ }
+
+ if (passed) {
+ results.passed++
+ } else {
+ console.error("failure", m)
+
+ results.failed++
+ }
+
+ results.total++
+
+ // console.log("emitted test", test)
+ socket.emit('test-result', test)
+ results.tests.push(test)
+ } else if (msg === '# ok' || msg.match(/^# tests \d+/)){
+ // console.log("emitted all test")
+ socket.emit('all-test-results', results)
+ }
+
+ // return false if you want to prevent the console message from
+ // going to the console
+ // return false
+ }
+ }
+}())