From 0de840efe648a5b033903184ded92200546f57ae Mon Sep 17 00:00:00 2001 From: Joel Kuzmarski Date: Thu, 20 Apr 2017 14:59:09 -0500 Subject: [PATCH 01/20] mocha and qunit tests working --- .gitignore | 1 + package.json | 12 ++++++++++-- test.js | 34 ++++++++++++++++++++++++++++++++++ test/resizes/resizes-test.html | 2 ++ test/resizes/resizes-test.js | 20 ++++++++++++++++++++ 5 files changed, 67 insertions(+), 2 deletions(-) create mode 100644 test/resizes/resizes-test.html create mode 100644 test/resizes/resizes-test.js diff --git a/.gitignore b/.gitignore index 31226a4..5a69a99 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ +test/**/generated-* node_modules/ temp/ diff --git a/package.json b/package.json index c562a18..c9e2ec0 100644 --- a/package.json +++ b/package.json @@ -25,14 +25,22 @@ "url": "https://github.com/bit-docs/bit-docs-tag-demo/issues" }, "homepage": "https://github.com/bit-docs/bit-docs-tag-demo#readme", + "steal": { + "plugins": [ + "steal-less" + ] + }, "dependencies": { - "bit-docs-process-tags": "^0.0.3", + "bit-docs-process-tags": "^0.0.5", "bit-docs-type-annotate": "^0.0.1" }, "devDependencies": { - "bit-docs-generate-html": "^0.2.0", + "bit-docs-generate-html": "0.5.0-pre.3", "connect": "^2.14.4", "mocha": "^2.5.3", + "steal": "^1.4.6", + "steal-less": "^1.2.0", + "steal-qunit": "^1.0.1", "zombie": "^4.2.1" } } diff --git a/test.js b/test.js index 85d729b..69b1197 100644 --- a/test.js +++ b/test.js @@ -90,4 +90,38 @@ describe("bit-docs-tag-demo", function(){ },done); }); }); + + it.only("client basics work", function(done) { + this.timeout(120000); + // emulate docMap promise (normally built from finders) + var docMap = Promise.resolve({ + index: { + name: "index", + demo: "path/to/demo.html", + body: "
\n" + } + }); + + generate(docMap, { + html: { + dependencies: { + "bit-docs-tag-demo": 'file:' + __dirname, + } + }, + dest: path.join(__dirname, "test/resizes/generated-resizes-test"), + parent: "index", + forceBuild: true, + debug: true, + minifyBuild: false + }).then(function(){ + done(); + // testee("generated-resizes-test.html").then(function(results) { + // results.forEach(function(result) { + // asset.ok(result.passed, result.message); + // }); + // }); + }, function(err) { + done(err); + }); + }); }); diff --git a/test/resizes/resizes-test.html b/test/resizes/resizes-test.html new file mode 100644 index 0000000..450eeea --- /dev/null +++ b/test/resizes/resizes-test.html @@ -0,0 +1,2 @@ + +
\ No newline at end of file diff --git a/test/resizes/resizes-test.js b/test/resizes/resizes-test.js new file mode 100644 index 0000000..f72c70a --- /dev/null +++ b/test/resizes/resizes-test.js @@ -0,0 +1,20 @@ +var QUnit = require("steal-qunit"); + +QUnit.module("bit-docs-tag-demo", { + beforeEach: function( assert ) { + var iframe = document.createElement('iframe'); + iframe.src = 'generated-resizes-test/index.html'; + QUnit.stop(); + var self = this; + iframe.onload = function() { + self.docWindow = this.contentWindow; + QUnit.start(); + }; + document.getElementById('qunit-fixture').appendChild(iframe); + } +}); + +QUnit.test("basics", function(assert){ + var demo = this.docWindow.document.querySelector('.demo'); + assert.equal( demo.querySelectorAll('li').length, 3, "there are three tabs" ); +}); \ No newline at end of file From 4a9fa09682c18913412f4b6a7f1d6c2fd99619d2 Mon Sep 17 00:00:00 2001 From: Joel Kuzmarski Date: Thu, 20 Apr 2017 21:45:35 -0500 Subject: [PATCH 02/20] zombie, connect, http, server-static --- package.json | 9 +++--- test.js | 80 ++++++++++++++++++++-------------------------------- 2 files changed, 35 insertions(+), 54 deletions(-) diff --git a/package.json b/package.json index c9e2ec0..a5b5bc5 100644 --- a/package.json +++ b/package.json @@ -35,12 +35,13 @@ "bit-docs-type-annotate": "^0.0.1" }, "devDependencies": { - "bit-docs-generate-html": "0.5.0-pre.3", - "connect": "^2.14.4", - "mocha": "^2.5.3", + "bit-docs-generate-html": "0.5.0-pre.4", + "connect": "^3.6.1", + "mocha": "^3.2.0", + "serve-static": "^1.12.1", "steal": "^1.4.6", "steal-less": "^1.2.0", "steal-qunit": "^1.0.1", - "zombie": "^4.2.1" + "zombie": "^5.0.5" } } diff --git a/test.js b/test.js index 69b1197..d58b937 100644 --- a/test.js +++ b/test.js @@ -3,41 +3,15 @@ var generate = require("bit-docs-generate-html/generate"); var path = require("path"); var Browser = require("zombie"), - connect = require("connect"); - - -var find = function(browser, property, callback, done){ - var start = new Date(); - var check = function(){ - if(browser.window && browser.window[property]) { - callback(browser.window[property]); - } else if(new Date() - start < 2000){ - setTimeout(check, 20); - } else { - done("failed to find "+property); - } - }; - check(); -}; -var waitFor = function(browser, checker, callback, done){ - var start = new Date(); - var check = function(){ - if(checker(browser.window)) { - callback(browser.window); - } else if(new Date() - start < 2000){ - setTimeout(check, 20); - } else { - done(new Error("checker was never true")); - } - }; - check(); -}; - + connect = require("connect"), + http = require('http'), + serveStatic = require('serve-static'); var open = function(url, callback, done){ - var server = connect().use(connect.static(path.join(__dirname))).listen(8081); + var app = connect().use(serveStatic(__dirname)); + var server = http.createServer(app).listen(8081, "127.0.0.1"); var browser = new Browser(); - browser.visit("http://localhost:8081/"+url) + browser.visit(url) .then(function(){ callback(browser, function(){ server.close(); @@ -48,8 +22,11 @@ var open = function(url, callback, done){ }); }; +Browser.localhost('127.0.0.1', 8081); + describe("bit-docs-tag-demo", function(){ - it("basics works", function(done){ + + it("basics works", function (done) { this.timeout(60000); var docMap = Promise.resolve({ @@ -63,7 +40,7 @@ describe("bit-docs-tag-demo", function(){ generate(docMap, { html: { dependencies: { - "bit-docs-tag-demo": __dirname + "bit-docs-tag-demo": 'file:' + __dirname } }, dest: path.join(__dirname, "temp"), @@ -71,29 +48,32 @@ describe("bit-docs-tag-demo", function(){ forceBuild: true, debug: true, minifyBuild: false - }).then(function(){ + }).then(function () { - open("temp/index.html",function(browser, close){ - waitFor(browser, function(window){ - return window.document.getElementsByClassName("demo").length; - }, function(){ - var doc = browser.window.document; - var tabs = doc.getElementsByClassName("tab"); + open("temp/index.html", function (browser, close) { + //browser.on('loaded', function(document) { + browser.assert.success(); + browser.assert.element('section.body'); + browser.assert.element('.demo'); - assert.equal(tabs.length, 3, "there are 3 tabs"); + var doc = browser.window.document; + var tabs = doc.getElementsByClassName("tab"); - // TODO better testing, click on stuff + assert.equal(tabs.length, 3, "there are 3 tabs"); - close(); - done(); - }); - },done); - }); + // TODO better testing, click on stuff + + close(); + done(); + //}); + }, done); + + }, done); }); - it.only("client basics work", function(done) { + it("client basics work", function(done) { this.timeout(120000); - // emulate docMap promise (normally built from finders) + var docMap = Promise.resolve({ index: { name: "index", From bfe90099116ff6c305e4a82ed74108601042cf9b Mon Sep 17 00:00:00 2001 From: Joel Kuzmarski Date: Thu, 20 Apr 2017 23:23:02 -0500 Subject: [PATCH 03/20] use express, comment out failing zombie asserts --- package.json | 45 ++++++++++++++++++++++----------------------- test.js | 44 +++++++++++++++++++------------------------- 2 files changed, 41 insertions(+), 48 deletions(-) diff --git a/package.json b/package.json index a5b5bc5..2c6aad3 100644 --- a/package.json +++ b/package.json @@ -2,33 +2,28 @@ "name": "bit-docs-tag-demo", "version": "0.3.0", "description": "@demo tag for bit-docs", - "main": "demo.js", - "scripts": { - "test": "mocha test.js --reporter spec", - "postversion": "git push --tags && git push", - "preversion": "npm test", - "release:pre": "npm version prerelease && npm publish", - "release:patch": "npm version patch && npm publish", - "release:minor": "npm version minor && npm publish", - "release:major": "npm version major && npm publish" - }, - "repository": { - "type": "git", - "url": "git+ssh://git@github.com/bit-docs/bit-docs-tag-demo.git" - }, "keywords": [ "bit-docs" ], - "author": "Bitovi", - "license": "MIT", + "homepage": "https://github.com/bit-docs/bit-docs-tag-demo#readme", "bugs": { "url": "https://github.com/bit-docs/bit-docs-tag-demo/issues" }, - "homepage": "https://github.com/bit-docs/bit-docs-tag-demo#readme", - "steal": { - "plugins": [ - "steal-less" - ] + "license": "MIT", + "author": "Bitovi", + "main": "demo.js", + "repository": { + "type": "git", + "url": "git+ssh://git@github.com/bit-docs/bit-docs-tag-demo.git" + }, + "scripts": { + "release:major": "npm version major && npm publish", + "release:minor": "npm version minor && npm publish", + "release:patch": "npm version patch && npm publish", + "release:pre": "npm version prerelease && npm publish", + "test": "mocha test.js --reporter spec", + "preversion": "npm test", + "postversion": "git push --tags && git push" }, "dependencies": { "bit-docs-process-tags": "^0.0.5", @@ -36,12 +31,16 @@ }, "devDependencies": { "bit-docs-generate-html": "0.5.0-pre.4", - "connect": "^3.6.1", + "express": "^4.15.2", "mocha": "^3.2.0", - "serve-static": "^1.12.1", "steal": "^1.4.6", "steal-less": "^1.2.0", "steal-qunit": "^1.0.1", "zombie": "^5.0.5" + }, + "steal": { + "plugins": [ + "steal-less" + ] } } diff --git a/test.js b/test.js index d58b937..75aef2c 100644 --- a/test.js +++ b/test.js @@ -1,15 +1,14 @@ -var assert = require("assert"); -var generate = require("bit-docs-generate-html/generate"); -var path = require("path"); +var assert = require("assert"), + generate = require("bit-docs-generate-html/generate"), + path = require("path"); var Browser = require("zombie"), - connect = require("connect"), - http = require('http'), - serveStatic = require('serve-static'); + express = require('express'); + +Browser.localhost('127.0.0.1', 8081); var open = function(url, callback, done){ - var app = connect().use(serveStatic(__dirname)); - var server = http.createServer(app).listen(8081, "127.0.0.1"); + var server = express().use('/', express.static(__dirname + '/')).listen(8081); var browser = new Browser(); browser.visit(url) .then(function(){ @@ -22,8 +21,6 @@ var open = function(url, callback, done){ }); }; -Browser.localhost('127.0.0.1', 8081); - describe("bit-docs-tag-demo", function(){ it("basics works", function (done) { @@ -51,21 +48,18 @@ describe("bit-docs-tag-demo", function(){ }).then(function () { open("temp/index.html", function (browser, close) { - //browser.on('loaded', function(document) { - browser.assert.success(); - browser.assert.element('section.body'); - browser.assert.element('.demo'); - - var doc = browser.window.document; - var tabs = doc.getElementsByClassName("tab"); - - assert.equal(tabs.length, 3, "there are 3 tabs"); - - // TODO better testing, click on stuff - - close(); - done(); - //}); + browser.assert.success(); + browser.assert.element('section.body'); + + // https://github.com/stealjs/steal/issues/1177 + // browser.assert.element('.demo'); + // var doc = browser.window.document; + // var tabs = doc.getElementsByClassName("tab"); + // assert.equal(tabs.length, 3, "there are 3 tabs"); + // TODO better testing, click on stuff + + close(); + done(); }, done); }, done); From 81263473f9acb2810b927fe3b014ed8349b643f3 Mon Sep 17 00:00:00 2001 From: Joel Kuzmarski Date: Fri, 21 Apr 2017 01:02:59 -0500 Subject: [PATCH 04/20] Add testee (WIP) --- package.json | 1 + test.js | 30 +++++++++++++++++------------- test/resizes/resizes-test.js | 27 ++++++++++++++------------- 3 files changed, 32 insertions(+), 26 deletions(-) diff --git a/package.json b/package.json index 2c6aad3..9585748 100644 --- a/package.json +++ b/package.json @@ -36,6 +36,7 @@ "steal": "^1.4.6", "steal-less": "^1.2.0", "steal-qunit": "^1.0.1", + "testee": "^0.4.0", "zombie": "^5.0.5" }, "steal": { diff --git a/test.js b/test.js index 75aef2c..459feb8 100644 --- a/test.js +++ b/test.js @@ -3,7 +3,8 @@ var assert = require("assert"), path = require("path"); var Browser = require("zombie"), - express = require('express'); + express = require('express'), + testee = require('testee'); Browser.localhost('127.0.0.1', 8081); @@ -65,8 +66,8 @@ describe("bit-docs-tag-demo", function(){ }, done); }); - it("client basics work", function(done) { - this.timeout(120000); + it.only("client basics work", function(done) { + this.timeout(60000); var docMap = Promise.resolve({ index: { @@ -88,14 +89,17 @@ describe("bit-docs-tag-demo", function(){ debug: true, minifyBuild: false }).then(function(){ - done(); - // testee("generated-resizes-test.html").then(function(results) { - // results.forEach(function(result) { - // asset.ok(result.passed, result.message); - // }); - // }); - }, function(err) { - done(err); - }); + testee.test(['test/resizes/resizes-test.html'], 'firefox', { + reporter: 'Spec' + }).then(function(results) { + console.log('123 results'); + console.dir(results); + console.dir(results[0].tests); + results.forEach(function(result) { + assert.ok(result.passed, result.message); + }); + done(); + }, done); + }, done); }); -}); +}); \ No newline at end of file diff --git a/test/resizes/resizes-test.js b/test/resizes/resizes-test.js index f72c70a..41ba0b1 100644 --- a/test/resizes/resizes-test.js +++ b/test/resizes/resizes-test.js @@ -1,20 +1,21 @@ var QUnit = require("steal-qunit"); QUnit.module("bit-docs-tag-demo", { - beforeEach: function( assert ) { - var iframe = document.createElement('iframe'); - iframe.src = 'generated-resizes-test/index.html'; - QUnit.stop(); - var self = this; - iframe.onload = function() { - self.docWindow = this.contentWindow; - QUnit.start(); - }; - document.getElementById('qunit-fixture').appendChild(iframe); - } + beforeEach: function (assert) { + var iframe = document.createElement('iframe'); + iframe.src = 'generated-resizes-test/index.html'; + QUnit.stop(); + var self = this; + iframe.onload = function () { + self.docWindow = this.contentWindow; + QUnit.start(); + }; + document.getElementById('qunit-fixture').appendChild(iframe); + } }); -QUnit.test("basics", function(assert){ +QUnit.test("basics", function () { var demo = this.docWindow.document.querySelector('.demo'); - assert.equal( demo.querySelectorAll('li').length, 3, "there are three tabs" ); + QUnit.equal(demo.querySelectorAll('li.tab').length, 3, "there are three tabs"); + QUnit.equal(demo.querySelectorAll('div.tab-content').length, 3, "there are three tab contents"); }); \ No newline at end of file From c700d5d5ebf5f0f01869b8b13e39292e4d4fa65c Mon Sep 17 00:00:00 2001 From: Joel Kuzmarski Date: Thu, 27 Apr 2017 18:21:46 -0500 Subject: [PATCH 05/20] Real tests using zombie --- package.json | 1 + test.js | 215 +++++++++++++++++++++++++++++---------------------- 2 files changed, 125 insertions(+), 91 deletions(-) diff --git a/package.json b/package.json index 9585748..4788c54 100644 --- a/package.json +++ b/package.json @@ -33,6 +33,7 @@ "bit-docs-generate-html": "0.5.0-pre.4", "express": "^4.15.2", "mocha": "^3.2.0", + "rimraf": "^2.6.1", "steal": "^1.4.6", "steal-less": "^1.2.0", "steal-qunit": "^1.0.1", diff --git a/test.js b/test.js index 459feb8..b24ea05 100644 --- a/test.js +++ b/test.js @@ -1,105 +1,138 @@ -var assert = require("assert"), - generate = require("bit-docs-generate-html/generate"), - path = require("path"); - -var Browser = require("zombie"), +var path = require('path'), + rmrf = require('rimraf'), + assert = require('assert'), + Browser = require('zombie'), express = require('express'), - testee = require('testee'); - -Browser.localhost('127.0.0.1', 8081); + generate = require('bit-docs-generate-html/generate'); -var open = function(url, callback, done){ - var server = express().use('/', express.static(__dirname + '/')).listen(8081); - var browser = new Browser(); - browser.visit(url) - .then(function(){ - callback(browser, function(){ - server.close(); - }); - }).catch(function(e){ - server.close(); - done(e) - }); -}; +Browser.localhost('*.example.com', 3003); -describe("bit-docs-tag-demo", function(){ +describe('bit-docs-tag-demo', function () { + var server = express(), + browser = new Browser(), + temp = path.join(__dirname, 'temp'); - it("basics works", function (done) { - this.timeout(60000); + before(function () { + return new Promise(function (resolve, reject) { + server = server.use('/', express.static(__dirname)).listen(3003, resolve); + server.on('error', reject); + }); + }); - var docMap = Promise.resolve({ - index: { - name: "index", - demo: "path/to/demo.html", - body: "
\n" - } + describe('temp directory', function () { + before(function (done) { + if (process.env.npm_config_generate == false) { this.skip(); } + rmrf(temp, done); }); - generate(docMap, { - html: { - dependencies: { - "bit-docs-tag-demo": 'file:' + __dirname + it('is generated', function () { + this.timeout(60000); + + var docMap = Promise.resolve({ + index: { + name: "index", + body: "
\n" } - }, - dest: path.join(__dirname, "temp"), - parent: "index", - forceBuild: true, - debug: true, - minifyBuild: false - }).then(function () { - - open("temp/index.html", function (browser, close) { - browser.assert.success(); - browser.assert.element('section.body'); - - // https://github.com/stealjs/steal/issues/1177 - // browser.assert.element('.demo'); - // var doc = browser.window.document; - // var tabs = doc.getElementsByClassName("tab"); - // assert.equal(tabs.length, 3, "there are 3 tabs"); - // TODO better testing, click on stuff - - close(); - done(); - }, done); - - }, done); + }); + + var siteConfig = { + html: { + dependencies: { + "bit-docs-tag-demo": 'file://' + __dirname + } + }, + dest: temp, + debug: process.env.npm_config_debug, + devBuild: process.env.npm_config_devBuild, + parent: "index", + forceBuild: true, + minifyBuild: false + }; + + return generate(docMap, siteConfig); + }); }); - it.only("client basics work", function(done) { - this.timeout(60000); + describe('demo widget', function () { + before(function () { + return browser.visit('/temp/index.html'); + }); - var docMap = Promise.resolve({ - index: { - name: "index", - demo: "path/to/demo.html", - body: "
\n" - } + it('exists on page', function () { + browser.assert.success(); + browser.assert.element('.demo_wrapper', 'wrapper exists'); + browser.assert.element('.demo_wrapper .demo', 'injected into wrapper'); }); - generate(docMap, { - html: { - dependencies: { - "bit-docs-tag-demo": 'file:' + __dirname, - } - }, - dest: path.join(__dirname, "test/resizes/generated-resizes-test"), - parent: "index", - forceBuild: true, - debug: true, - minifyBuild: false - }).then(function(){ - testee.test(['test/resizes/resizes-test.html'], 'firefox', { - reporter: 'Spec' - }).then(function(results) { - console.log('123 results'); - console.dir(results); - console.dir(results[0].tests); - results.forEach(function(result) { - assert.ok(result.passed, result.message); - }); - done(); - }, done); - }, done); + describe('tabs and contents', function () { + it('has three', function () { + browser.assert.elements('.tab', 3, 'there are three tabs'); + browser.assert.elements('.tab-content', 3, 'there are three tab contents'); + }); + + it('only one active', function () { + browser.assert.element('.tab.active', 'only one tab is active'); + browser.assert.element('.tab-content[style*="block"]', 'only one tab content is visible'); + }); + + it('defaults to demo', function () { + browser.assert.text('.tab.active', 'Demo', 'Demo is active tab text'); + browser.assert.attribute('.tab.active', 'data-tab', 'demo', 'demo is active data-tab'); + browser.assert.style('[data-for="demo"]', 'display', 'block', 'demo tab content is visible'); + }); + }); + + describe('clicking HTML tab', function () { + before(function () { + return browser.click('[data-tab="html"]'); + }); + + it('changes active tab and content', function () { + browser.assert.attribute('.tab.active', 'data-tab', 'html', 'html is active data-tab'); + browser.assert.style('[data-for="html"]', 'display', 'block', 'html tab content is visible'); + }); + }); + }); + + after(function () { + browser.destroy(); + server.close(); }); -}); \ No newline at end of file +}); + + // it.only("client basics work", function(done) { + // this.timeout(60000); + + // var docMap = Promise.resolve({ + // index: { + // name: "index", + // demo: "path/to/demo.html", + // body: "
\n" + // } + // }); + + // generate(docMap, { + // html: { + // dependencies: { + // "bit-docs-tag-demo": 'file:' + __dirname, + // } + // }, + // dest: path.join(__dirname, "test/resizes/generated-resizes-test"), + // parent: "index", + // forceBuild: true, + // debug: true, + // minifyBuild: false + // }).then(function(){ + // testee.test(['test/resizes/resizes-test.html'], 'firefox', { + // reporter: 'Spec' + // }).then(function(results) { + // console.log('123 results'); + // console.dir(results); + // console.dir(results[0].tests); + // results.forEach(function(result) { + // assert.ok(result.passed, result.message); + // }); + // done(); + // }, done); + // }, done); + // }); \ No newline at end of file From 05b61a792f2b5e7f398984fa9772609717b12ad3 Mon Sep 17 00:00:00 2001 From: Joel Kuzmarski Date: Thu, 27 Apr 2017 18:22:35 -0500 Subject: [PATCH 06/20] zombie uses jsdom which does not support dataset --- demo_frame.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/demo_frame.js b/demo_frame.js index d58f1d3..782aca6 100644 --- a/demo_frame.js +++ b/demo_frame.js @@ -101,7 +101,7 @@ module.exports = function(node){ node.querySelector("ul").addEventListener("click", function(ev){ var el = ev.target; if(el.className === "tab") { - toggle(el.dataset.tab); + toggle(el.dataset ? el.dataset.tab : el.getAttribute("data-tab")); } }); toggle("demo"); From 78c0fe347d238c221a5de0bc6df482a634e2405a Mon Sep 17 00:00:00 2001 From: Joel Kuzmarski Date: Fri, 28 Apr 2017 02:40:21 -0500 Subject: [PATCH 07/20] Make demo_frame.js smarter --- demo_frame.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/demo_frame.js b/demo_frame.js index 782aca6..42c933d 100644 --- a/demo_frame.js +++ b/demo_frame.js @@ -45,9 +45,11 @@ module.exports = function(node){ var dataForHtml = node.querySelector("[data-for=html] > pre"); dataForHtml.innerHTML = prettyify(html); - var dataForJS = node.querySelector("[data-for=js] > pre"); - dataForJS.innerHTML = prettyify(js.replace(/\t/g," ")); - show(node.querySelector("[data-tab=js]")); + if (js) { + var dataForJS = node.querySelector("[data-for=js] > pre"); + dataForJS.innerHTML = prettyify(js.replace(/\t/g," ")); + show(node.querySelector("[data-tab=js]")); + } tabs(); } @@ -86,11 +88,11 @@ module.exports = function(node){ } } } - return source.trim(); + return (source ? source.trim() : false); } function show(el) { - el.style.display = "block"; + el.style.display = ""; } function hide(el) { From c359ecfdbf94e928808f3bdae1fab73da160d448 Mon Sep 17 00:00:00 2001 From: Joel Kuzmarski Date: Fri, 28 Apr 2017 02:40:40 -0500 Subject: [PATCH 08/20] More comprehensive tests --- test.js | 163 +++++++++++------- test/basics/demo-complex.html | 17 ++ test/basics/demo-with-ids.html | 6 + .../{demo.html => demo-without-ids.html} | 0 test/basics/demo-without-js.html | 1 + 5 files changed, 121 insertions(+), 66 deletions(-) create mode 100644 test/basics/demo-complex.html create mode 100644 test/basics/demo-with-ids.html rename test/basics/{demo.html => demo-without-ids.html} (100%) create mode 100644 test/basics/demo-without-js.html diff --git a/test.js b/test.js index b24ea05..a98b08e 100644 --- a/test.js +++ b/test.js @@ -13,6 +13,7 @@ describe('bit-docs-tag-demo', function () { temp = path.join(__dirname, 'temp'); before(function () { + if (!!process.env.npm_config_debug) { browser.debug(); } return new Promise(function (resolve, reject) { server = server.use('/', express.static(__dirname)).listen(3003, resolve); server.on('error', reject); @@ -21,17 +22,30 @@ describe('bit-docs-tag-demo', function () { describe('temp directory', function () { before(function (done) { - if (process.env.npm_config_generate == false) { this.skip(); } + if (!!process.env.npm_config_skipGenerate) { this.skip(); } rmrf(temp, done); }); it('is generated', function () { this.timeout(60000); + function demo_wrapper(path) { + return '
' + "\n" + } + var docMap = Promise.resolve({ - index: { + withIds: { + name: "withIds", + body: demo_wrapper('demo-with-ids') + }, withoutIds: { + name: "withoutIds", + body: demo_wrapper('demo-without-ids') + }, withoutJs: { + name: "withoutJs", + body: demo_wrapper('demo-without-js') + }, index: { name: "index", - body: "
\n" + body: demo_wrapper('demo-with-ids') + demo_wrapper('demo-without-ids') + demo_wrapper('demo-without-js') } }); @@ -42,8 +56,8 @@ describe('bit-docs-tag-demo', function () { } }, dest: temp, - debug: process.env.npm_config_debug, - devBuild: process.env.npm_config_devBuild, + debug: !!process.env.npm_config_debug, + devBuild: !!process.env.npm_config_devBuild, parent: "index", forceBuild: true, minifyBuild: false @@ -54,42 +68,96 @@ describe('bit-docs-tag-demo', function () { }); describe('demo widget', function () { - before(function () { - return browser.visit('/temp/index.html'); - }); + function basicsWork() { + it('exists on page', function () { + browser.assert.success(); + browser.assert.element('.demo_wrapper', 'wrapper exists'); + browser.assert.element('.demo_wrapper .demo', 'injected into wrapper'); + }); + + describe('tabs and contents', function () { + it('has three', function () { + browser.assert.elements('.tab', 3, 'there are three tabs'); + browser.assert.elements('.tab-content', 3, 'there are three tab contents'); + }); + + it('only one active', function () { + browser.assert.element('.tab.active', 'only one tab is active'); + browser.assert.element('.tab-content:not([style*="none"])', 'only one tab content is visible'); + }); + + it('defaults to demo', function () { + browser.assert.text('.tab.active', 'Demo', 'Demo is active tab text'); + browser.assert.attribute('.tab.active', 'data-tab', 'demo', 'demo is active data-tab'); + browser.assert.style('[data-for="demo"]', 'display', '', 'demo tab content is visible'); + }); + }); + + describe('clicking HTML tab', function () { + before(function () { + return browser.click('[data-tab="html"]'); + }); + + it('changes tab and content', function () { + browser.assert.attribute('.tab.active', 'data-tab', 'html', 'html is active data-tab'); + browser.assert.style('[data-for="html"]', 'display', '', 'html tab content is visible'); + }); + }); + } + + describe('with ids', function () { + before(function () { + return browser.visit('/temp/withIds.html'); + }); - it('exists on page', function () { - browser.assert.success(); - browser.assert.element('.demo_wrapper', 'wrapper exists'); - browser.assert.element('.demo_wrapper .demo', 'injected into wrapper'); + basicsWork(); }); - describe('tabs and contents', function () { - it('has three', function () { - browser.assert.elements('.tab', 3, 'there are three tabs'); - browser.assert.elements('.tab-content', 3, 'there are three tab contents'); + describe('without ids', function () { + before(function () { + return browser.visit('/temp/withoutIds.html'); }); - it('only one active', function () { - browser.assert.element('.tab.active', 'only one tab is active'); - browser.assert.element('.tab-content[style*="block"]', 'only one tab content is visible'); + basicsWork(); + }); + + describe('without js', function () { + before(function () { + return browser.visit('/temp/withoutJs.html'); }); - it('defaults to demo', function () { - browser.assert.text('.tab.active', 'Demo', 'Demo is active tab text'); - browser.assert.attribute('.tab.active', 'data-tab', 'demo', 'demo is active data-tab'); - browser.assert.style('[data-for="demo"]', 'display', 'block', 'demo tab content is visible'); + basicsWork(); + + describe('JS tab', function () { + it('is hidden', function () { + browser.assert.style('[data-tab="js"]', 'display', 'none', 'js tab content is hidden'); + }); }); }); - describe('clicking HTML tab', function () { + describe('multiple instances', function () { before(function () { - return browser.click('[data-tab="html"]'); + return browser.visit('/temp/index.html'); + }); + + it('exist on page', function () { + browser.assert.success(); + browser.assert.elements('.demo_wrapper', 3, 'three wrappers exists'); + browser.assert.elements('.demo_wrapper .demo', 3, 'three injected into wrappers'); }); - it('changes active tab and content', function () { - browser.assert.attribute('.tab.active', 'data-tab', 'html', 'html is active data-tab'); - browser.assert.style('[data-for="html"]', 'display', 'block', 'html tab content is visible'); + describe('clicking all HTML tabs', function () { + before(function () { + var htmlTabs = browser.queryAll('[data-tab="html"]'); + return Promise.all(htmlTabs.map(function(el) { + browser.click(el); + })); + }); + + it('changes tabs and contents', function () { + browser.assert.attribute('.tab.active', 'data-tab', 'html', 'html is active data-tab'); + browser.assert.style('[data-for="html"]', 'display', '', 'html tab content is visible'); + }); }); }); }); @@ -98,41 +166,4 @@ describe('bit-docs-tag-demo', function () { browser.destroy(); server.close(); }); -}); - - // it.only("client basics work", function(done) { - // this.timeout(60000); - - // var docMap = Promise.resolve({ - // index: { - // name: "index", - // demo: "path/to/demo.html", - // body: "
\n" - // } - // }); - - // generate(docMap, { - // html: { - // dependencies: { - // "bit-docs-tag-demo": 'file:' + __dirname, - // } - // }, - // dest: path.join(__dirname, "test/resizes/generated-resizes-test"), - // parent: "index", - // forceBuild: true, - // debug: true, - // minifyBuild: false - // }).then(function(){ - // testee.test(['test/resizes/resizes-test.html'], 'firefox', { - // reporter: 'Spec' - // }).then(function(results) { - // console.log('123 results'); - // console.dir(results); - // console.dir(results[0].tests); - // results.forEach(function(result) { - // assert.ok(result.passed, result.message); - // }); - // done(); - // }, done); - // }, done); - // }); \ No newline at end of file +}); \ No newline at end of file diff --git a/test/basics/demo-complex.html b/test/basics/demo-complex.html new file mode 100644 index 0000000..d694c43 --- /dev/null +++ b/test/basics/demo-complex.html @@ -0,0 +1,17 @@ + + + \ No newline at end of file diff --git a/test/basics/demo-with-ids.html b/test/basics/demo-with-ids.html new file mode 100644 index 0000000..f0c3f53 --- /dev/null +++ b/test/basics/demo-with-ids.html @@ -0,0 +1,6 @@ +
Hello world!
+ diff --git a/test/basics/demo.html b/test/basics/demo-without-ids.html similarity index 100% rename from test/basics/demo.html rename to test/basics/demo-without-ids.html diff --git a/test/basics/demo-without-js.html b/test/basics/demo-without-js.html new file mode 100644 index 0000000..6bc5938 --- /dev/null +++ b/test/basics/demo-without-js.html @@ -0,0 +1 @@ +
Hello world!
\ No newline at end of file From 476ff1e93130bf349b7033a1d12f9890fc539a48 Mon Sep 17 00:00:00 2001 From: Joel Kuzmarski Date: Fri, 28 Apr 2017 03:30:20 -0500 Subject: [PATCH 09/20] Verify HTML and JS content in tests --- test.js | 65 +++++++++++++++++++++++++++++-- test/basics/demo-with-ids.html | 2 +- test/basics/demo-without-ids.html | 2 +- test/basics/demo-without-js.html | 2 +- 4 files changed, 64 insertions(+), 7 deletions(-) diff --git a/test.js b/test.js index a98b08e..36cf31b 100644 --- a/test.js +++ b/test.js @@ -111,6 +111,26 @@ describe('bit-docs-tag-demo', function () { }); basicsWork(); + + describe('HTML', function () { + it('has correct content', function () { + browser.assert.text( + '[data-for="html"] pre', + 'Hello world!', + 'html tab content is correct'); + }); + }); + + describe('JS', function () { + it('has correct content', function () { + browser.assert.text( + '[data-for="js"] pre', [ + 'var div = document.createElement("div");', + 'div.textContent = "it worked!";', + 'document.body.appendChild(div);' + ].join(' '), 'js tab content is correct'); + }); + }); }); describe('without ids', function () { @@ -119,6 +139,27 @@ describe('bit-docs-tag-demo', function () { }); basicsWork(); + + describe('HTML', function () { + it('has correct content', function () { + browser.assert.text( + '[data-for="html"] pre', [ + '
Hello world!
', + '
it worked!
' + ].join(' '), 'html tab content is correct'); + }); + }); + + describe('JS', function () { + it('has correct content', function () { + browser.assert.text( + '[data-for="js"] pre', [ + 'var div = document.createElement("div");', + 'div.textContent = "it worked!";', + 'document.body.appendChild(div);' + ].join(' '), 'js tab content is correct'); + }); + }); }); describe('without js', function () { @@ -128,9 +169,25 @@ describe('bit-docs-tag-demo', function () { basicsWork(); - describe('JS tab', function () { - it('is hidden', function () { - browser.assert.style('[data-tab="js"]', 'display', 'none', 'js tab content is hidden'); + describe('HTML', function () { + it('has correct content', function () { + browser.assert.text( + '[data-for="html"] pre', + 'Hello world!', + 'html tab content is correct'); + }); + }); + + describe('JS', function () { + it('tab is hidden', function () { + browser.assert.style('[data-tab="js"]', 'display', 'none', 'js tab is hidden'); + }); + + it('has no content', function () { + browser.assert.text( + '[data-for="js"] pre', + '', + 'js tab content is empty'); }); }); }); @@ -154,7 +211,7 @@ describe('bit-docs-tag-demo', function () { })); }); - it('changes tabs and contents', function () { + it('changes all tabs and contents', function () { browser.assert.attribute('.tab.active', 'data-tab', 'html', 'html is active data-tab'); browser.assert.style('[data-for="html"]', 'display', '', 'html tab content is visible'); }); diff --git a/test/basics/demo-with-ids.html b/test/basics/demo-with-ids.html index f0c3f53..6386786 100644 --- a/test/basics/demo-with-ids.html +++ b/test/basics/demo-with-ids.html @@ -1,4 +1,4 @@ -
Hello world!
+
Hello world!
-
\ No newline at end of file diff --git a/test/resizes/resizes-test.js b/test/resizes/resizes-test.js deleted file mode 100644 index 41ba0b1..0000000 --- a/test/resizes/resizes-test.js +++ /dev/null @@ -1,21 +0,0 @@ -var QUnit = require("steal-qunit"); - -QUnit.module("bit-docs-tag-demo", { - beforeEach: function (assert) { - var iframe = document.createElement('iframe'); - iframe.src = 'generated-resizes-test/index.html'; - QUnit.stop(); - var self = this; - iframe.onload = function () { - self.docWindow = this.contentWindow; - QUnit.start(); - }; - document.getElementById('qunit-fixture').appendChild(iframe); - } -}); - -QUnit.test("basics", function () { - var demo = this.docWindow.document.querySelector('.demo'); - QUnit.equal(demo.querySelectorAll('li.tab').length, 3, "there are three tabs"); - QUnit.equal(demo.querySelectorAll('div.tab-content').length, 3, "there are three tab contents"); -}); \ No newline at end of file From 00d53adf944af2ca113c7ba5c6b93da73b5b780e Mon Sep 17 00:00:00 2001 From: Joel Kuzmarski Date: Sat, 29 Apr 2017 00:30:04 -0500 Subject: [PATCH 12/20] Add complex demo test --- package.json | 7 +++- test.js | 61 +++++++++++++++++++++++++++++++---- test/basics/demo-complex.html | 5 +-- 3 files changed, 64 insertions(+), 9 deletions(-) diff --git a/package.json b/package.json index c75539d..b6f6518 100644 --- a/package.json +++ b/package.json @@ -27,6 +27,11 @@ }, "devDependencies": { "bit-docs-generate-html": "0.5.0-pre.4", + "can-define": "1.0.17", + "can-stache": "3.0.20", + "can-stache-bindings": "3.0.13", + "can-view-autorender": "3.0.4", + "can-view-model": "3.1.3", "express": "^4.15.2", "mocha": "^3.2.0", "rimraf": "^2.6.1", @@ -39,4 +44,4 @@ "steal-less" ] } -} \ No newline at end of file +} diff --git a/test.js b/test.js index 9dd4def..d70975d 100644 --- a/test.js +++ b/test.js @@ -7,6 +7,15 @@ var path = require('path'), Browser.localhost('*.example.com', 3003); +/* + * Debug options: + * npm --debug test + * npm --devBuild test + * npm --skipGenerate test + * npm --debug --devBuild test + * npm --debug --skipGenerate test + */ + describe('bit-docs-tag-demo', function () { var server = express(), browser = new Browser(), @@ -33,6 +42,13 @@ describe('bit-docs-tag-demo', function () { return '
' + "\n" } + function all_demos() { + return demo_wrapper('demo-with-ids') + "\n" + + demo_wrapper('demo-without-ids') + "\n" + + demo_wrapper('demo-without-js') + "\n" + + demo_wrapper('demo-complex'); + } + var docMap = Promise.resolve({ withIds: { name: "withIds", @@ -43,9 +59,12 @@ describe('bit-docs-tag-demo', function () { }, withoutJs: { name: "withoutJs", body: demo_wrapper('demo-without-js') + }, complex: { + name: "complex", + body: demo_wrapper('demo-complex') }, index: { name: "index", - body: demo_wrapper('demo-with-ids') + demo_wrapper('demo-without-ids') + demo_wrapper('demo-without-js') + body: all_demos() } }); @@ -88,7 +107,7 @@ describe('bit-docs-tag-demo', function () { }); it('defaults to demo', function () { - browser.assert.text('.tab.active', 'Demo', 'Demo is active tab text'); + browser.assert.text('.tab.active', 'Demo', '"Demo" is active tab text'); browser.assert.attribute('.tab.active', 'data-tab', 'demo', 'demo is active data-tab'); browser.assert.style('[data-for="demo"]', 'display', '', 'demo tab content is visible'); }); @@ -133,7 +152,9 @@ describe('bit-docs-tag-demo', function () { function dataforAssert(selector, strings) { describe('data-for=' + selector, function () { before(function () { - strings = (strings instanceof Array) ? strings.join(' ') : strings; + if (strings instanceof Array) { + strings = strings.join(' '); + } }); it('has correct content', function () { @@ -209,7 +230,7 @@ describe('bit-docs-tag-demo', function () { }); describe('JS', function () { - // has no content + // expect no content dataforAssert('js', ''); it('tab is hidden', function () { @@ -218,15 +239,43 @@ describe('bit-docs-tag-demo', function () { }); }); + describe('complex', function () { + this.timeout(4000); + + before(function () { + return browser.visit('/temp/complex.html'); + }); + + basicsWork(); + + describe('Demo', function () { + iframeAssert('demo-complex', /CanJS is cool/); + }); + + describe('HTML', function () { + dataforAssert('html', [ + '{{#each items}}', + '
  • {{name}}
  • ', + '{{/each}}' + ]); + }); + + describe('JS', function () { + dataforAssert('js', /viewModel/); + }); + }); + describe('multiple instances', function () { + this.timeout(8000); + before(function () { return browser.visit('/temp/index.html'); }); it('exist on page', function () { browser.assert.success(); - browser.assert.elements('.demo_wrapper', 3, 'three wrappers exists'); - browser.assert.elements('.demo_wrapper .demo', 3, 'three injected into wrappers'); + browser.assert.elements('.demo_wrapper', 4, 'four wrappers exists'); + browser.assert.elements('.demo_wrapper .demo', 4, 'four injected into wrappers'); }); describe('clicking all HTML tabs', function () { diff --git a/test/basics/demo-complex.html b/test/basics/demo-complex.html index d694c43..93d9df6 100644 --- a/test/basics/demo-complex.html +++ b/test/basics/demo-complex.html @@ -1,8 +1,9 @@ + \ No newline at end of file From ffbd91dbb3b3e6a1897d82a57110f0cc6d1ee907 Mon Sep 17 00:00:00 2001 From: Joel Kuzmarski Date: Tue, 9 May 2017 15:15:36 -0500 Subject: [PATCH 13/20] Remove can-stache-bindings dependency --- package.json | 1 - test/basics/demo-complex.html | 3 +-- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/package.json b/package.json index b6f6518..0a15952 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,6 @@ "bit-docs-generate-html": "0.5.0-pre.4", "can-define": "1.0.17", "can-stache": "3.0.20", - "can-stache-bindings": "3.0.13", "can-view-autorender": "3.0.4", "can-view-model": "3.1.3", "express": "^4.15.2", diff --git a/test/basics/demo-complex.html b/test/basics/demo-complex.html index 93d9df6..f6d45e1 100644 --- a/test/basics/demo-complex.html +++ b/test/basics/demo-complex.html @@ -7,7 +7,6 @@ \ No newline at end of file + From 5f017c6f9e4ceeecbf4d7ab9878d0ce651b4da05 Mon Sep 17 00:00:00 2001 From: Joel Kuzmarski Date: Tue, 9 May 2017 15:16:16 -0500 Subject: [PATCH 14/20] Return empty string instead false --- demo_frame.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/demo_frame.js b/demo_frame.js index 42c933d..4049471 100644 --- a/demo_frame.js +++ b/demo_frame.js @@ -88,7 +88,7 @@ module.exports = function(node){ } } } - return (source ? source.trim() : false); + return (source ? source.trim() : ''); } function show(el) { From c1224ca5ebe35be8b52be7fbedea3f9fcc62d4de Mon Sep 17 00:00:00 2001 From: Joel Kuzmarski Date: Tue, 9 May 2017 15:16:40 -0500 Subject: [PATCH 15/20] Separate var statements to one line each --- test.js | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/test.js b/test.js index d70975d..e881b8b 100644 --- a/test.js +++ b/test.js @@ -1,9 +1,9 @@ -var path = require('path'), - rmrf = require('rimraf'), - assert = require('assert'), - Browser = require('zombie'), - express = require('express'), - generate = require('bit-docs-generate-html/generate'); +var Browser = require('zombie'); +var assert = require('assert'); +var express = require('express'); +var generate = require('bit-docs-generate-html/generate'); +var path = require('path'); +var rmrf = require('rimraf'); Browser.localhost('*.example.com', 3003); @@ -17,9 +17,9 @@ Browser.localhost('*.example.com', 3003); */ describe('bit-docs-tag-demo', function () { - var server = express(), - browser = new Browser(), - temp = path.join(__dirname, 'temp'); + var server = express(); + var browser = new Browser(); + var temp = path.join(__dirname, 'temp'); before(function () { if (!!process.env.npm_config_debug) { browser.debug(); } @@ -127,7 +127,8 @@ describe('bit-docs-tag-demo', function () { function iframeAssert(path, regex) { describe('iframe (' + path + '.html)', function () { - var iframe, iframeDocument; + var iframe; + var iframeDocument; before(function () { iframe = browser.query('iframe'); @@ -298,4 +299,4 @@ describe('bit-docs-tag-demo', function () { browser.destroy(); server.close(); }); -}); \ No newline at end of file +}); From 6fe23a538c0c8bebe60a8f58573d26f99f3d8922 Mon Sep 17 00:00:00 2001 From: Joel Kuzmarski Date: Tue, 9 May 2017 16:05:27 -0500 Subject: [PATCH 16/20] Sort var statements alphabetically --- test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test.js b/test.js index e881b8b..4f08705 100644 --- a/test.js +++ b/test.js @@ -17,8 +17,8 @@ Browser.localhost('*.example.com', 3003); */ describe('bit-docs-tag-demo', function () { - var server = express(); var browser = new Browser(); + var server = express(); var temp = path.join(__dirname, 'temp'); before(function () { From e12d5ad15b5b4fdca0ff20dc13dcb140fcebc65c Mon Sep 17 00:00:00 2001 From: Joel Kuzmarski Date: Tue, 9 May 2017 17:09:51 -0500 Subject: [PATCH 17/20] Make things more readable --- test.js | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/test.js b/test.js index 4f08705..41a55cc 100644 --- a/test.js +++ b/test.js @@ -22,7 +22,10 @@ describe('bit-docs-tag-demo', function () { var temp = path.join(__dirname, 'temp'); before(function () { - if (!!process.env.npm_config_debug) { browser.debug(); } + if (!!process.env.npm_config_debug) { + browser.debug(); + } + return new Promise(function (resolve, reject) { server = server.use('/', express.static(__dirname)).listen(3003, resolve); server.on('error', reject); @@ -31,7 +34,10 @@ describe('bit-docs-tag-demo', function () { describe('temp directory', function () { before(function (done) { - if (!!process.env.npm_config_skipGenerate) { this.skip(); } + if (!!process.env.npm_config_skipGenerate) { + this.skip(); + } + rmrf(temp, done); }); @@ -43,10 +49,14 @@ describe('bit-docs-tag-demo', function () { } function all_demos() { - return demo_wrapper('demo-with-ids') + "\n" + - demo_wrapper('demo-without-ids') + "\n" + - demo_wrapper('demo-without-js') + "\n" + - demo_wrapper('demo-complex'); + return [ + 'demo-with-ids', + 'demo-without-ids', + 'demo-without-js', + 'demo-complex' + ].map(function (demo) { + return '

    ' + demo + '

    ' + demo_wrapper(demo); + }).join('
    '); } var docMap = Promise.resolve({ @@ -143,6 +153,7 @@ describe('bit-docs-tag-demo', function () { it('has correct content', function () { assert(/Hello world/.test(iframeDocument.body.innerHTML)); + if (regex instanceof RegExp) { assert(regex.test(iframeDocument.body.innerHTML)); } @@ -282,6 +293,7 @@ describe('bit-docs-tag-demo', function () { describe('clicking all HTML tabs', function () { before(function () { var htmlTabs = browser.queryAll('[data-tab="html"]'); + return Promise.all(htmlTabs.map(function (el) { browser.click(el); })); From 2a3450d74539609aee50a4d0b9982b7a60c0c9ab Mon Sep 17 00:00:00 2001 From: Joel Kuzmarski Date: Tue, 9 May 2017 18:05:02 -0500 Subject: [PATCH 18/20] Move things around for organization --- .gitignore | 2 +- test.js | 18 +++++++++--------- test/{basics => demos}/demo-complex.html | 0 test/{basics => demos}/demo-with-ids.html | 0 test/{basics => demos}/demo-without-ids.html | 0 test/{basics => demos}/demo-without-js.html | 0 6 files changed, 10 insertions(+), 10 deletions(-) rename test/{basics => demos}/demo-complex.html (100%) rename test/{basics => demos}/demo-with-ids.html (100%) rename test/{basics => demos}/demo-without-ids.html (100%) rename test/{basics => demos}/demo-without-js.html (100%) diff --git a/.gitignore b/.gitignore index 31226a4..c7ed7ea 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,2 @@ node_modules/ -temp/ +test/temp/ diff --git a/test.js b/test.js index 41a55cc..0f777ab 100644 --- a/test.js +++ b/test.js @@ -19,7 +19,7 @@ Browser.localhost('*.example.com', 3003); describe('bit-docs-tag-demo', function () { var browser = new Browser(); var server = express(); - var temp = path.join(__dirname, 'temp'); + var temp = path.join(__dirname, 'test', 'temp'); before(function () { if (!!process.env.npm_config_debug) { @@ -45,7 +45,7 @@ describe('bit-docs-tag-demo', function () { this.timeout(60000); function demo_wrapper(path) { - return '
    ' + "\n" + return '
    ' + "\n" } function all_demos() { @@ -146,8 +146,8 @@ describe('bit-docs-tag-demo', function () { }); it('has correct url and parent', function () { - assert.equal(iframe.src, '../test/basics/' + path + '.html'); - assert.equal(iframeDocument.URL, 'http://example.com/test/basics/' + path + '.html'); + assert.equal(iframe.src, '../demos/' + path + '.html'); + assert.equal(iframeDocument.URL, 'http://example.com/test/demos/' + path + '.html'); assert.equal(iframe.contentWindow.parent, browser.window.parent); }); @@ -177,7 +177,7 @@ describe('bit-docs-tag-demo', function () { describe('with ids', function () { before(function () { - return browser.visit('/temp/withIds.html'); + return browser.visit('/test/temp/withIds.html'); }); basicsWork(); @@ -201,7 +201,7 @@ describe('bit-docs-tag-demo', function () { describe('without ids', function () { before(function () { - return browser.visit('/temp/withoutIds.html'); + return browser.visit('/test/temp/withoutIds.html'); }); basicsWork(); @@ -228,7 +228,7 @@ describe('bit-docs-tag-demo', function () { describe('without js', function () { before(function () { - return browser.visit('/temp/withoutJs.html'); + return browser.visit('/test/temp/withoutJs.html'); }); basicsWork(); @@ -255,7 +255,7 @@ describe('bit-docs-tag-demo', function () { this.timeout(4000); before(function () { - return browser.visit('/temp/complex.html'); + return browser.visit('/test/temp/complex.html'); }); basicsWork(); @@ -281,7 +281,7 @@ describe('bit-docs-tag-demo', function () { this.timeout(8000); before(function () { - return browser.visit('/temp/index.html'); + return browser.visit('/test/temp/index.html'); }); it('exist on page', function () { diff --git a/test/basics/demo-complex.html b/test/demos/demo-complex.html similarity index 100% rename from test/basics/demo-complex.html rename to test/demos/demo-complex.html diff --git a/test/basics/demo-with-ids.html b/test/demos/demo-with-ids.html similarity index 100% rename from test/basics/demo-with-ids.html rename to test/demos/demo-with-ids.html diff --git a/test/basics/demo-without-ids.html b/test/demos/demo-without-ids.html similarity index 100% rename from test/basics/demo-without-ids.html rename to test/demos/demo-without-ids.html diff --git a/test/basics/demo-without-js.html b/test/demos/demo-without-js.html similarity index 100% rename from test/basics/demo-without-js.html rename to test/demos/demo-without-js.html From def26e730369dce80d93185b4c5ebd645bfd5a75 Mon Sep 17 00:00:00 2001 From: Joel Kuzmarski Date: Wed, 10 May 2017 10:25:30 -0500 Subject: [PATCH 19/20] Encapsulate complex demo dependencies Still need to automate npm install, and make work with zombie. --- .gitignore | 1 + package.json | 6 +--- .../{ => demo-complex}/demo-complex.html | 2 +- test/demos/demo-complex/package.json | 14 ++++++++ test.js => test/test.js | 34 +++++++++---------- 5 files changed, 34 insertions(+), 23 deletions(-) rename test/demos/{ => demo-complex}/demo-complex.html (83%) create mode 100644 test/demos/demo-complex/package.json rename test.js => test/test.js (90%) diff --git a/.gitignore b/.gitignore index c7ed7ea..644c435 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ +test/demos/demo-complex/node_modules node_modules/ test/temp/ diff --git a/package.json b/package.json index 0a15952..6af79ca 100644 --- a/package.json +++ b/package.json @@ -21,16 +21,12 @@ "release:minor": "npm version minor && npm publish", "release:patch": "npm version patch && npm publish", "release:pre": "npm version prerelease && npm publish", - "test": "mocha test.js --reporter spec", + "test": "mocha test/test.js --reporter spec", "preversion": "npm test", "postversion": "git push --tags && git push" }, "devDependencies": { "bit-docs-generate-html": "0.5.0-pre.4", - "can-define": "1.0.17", - "can-stache": "3.0.20", - "can-view-autorender": "3.0.4", - "can-view-model": "3.1.3", "express": "^4.15.2", "mocha": "^3.2.0", "rimraf": "^2.6.1", diff --git a/test/demos/demo-complex.html b/test/demos/demo-complex/demo-complex.html similarity index 83% rename from test/demos/demo-complex.html rename to test/demos/demo-complex/demo-complex.html index f6d45e1..c21de92 100644 --- a/test/demos/demo-complex.html +++ b/test/demos/demo-complex/demo-complex.html @@ -5,7 +5,7 @@ - diff --git a/test/demos/demo-complex/demo-complex.html b/test/demos/demo-complex/demo-complex.html deleted file mode 100644 index c21de92..0000000 --- a/test/demos/demo-complex/demo-complex.html +++ /dev/null @@ -1,17 +0,0 @@ - - - - diff --git a/test/demos/demo-complex/package.json b/test/demos/demo-complex/package.json deleted file mode 100644 index 49b5008..0000000 --- a/test/demos/demo-complex/package.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "name": "demo-complex", - "version": "0.0.1", - "license": "MIT", - "author": "Bitovi", - "main": "index.js", - "dependencies": { - "can-define": "1.0.17", - "can-stache": "3.0.20", - "can-view-autorender": "3.0.4", - "can-view-model": "3.1.3", - "steal": "1.5.2" - } -} \ No newline at end of file