Merge pull request #90 from Fraham/Feature-UnitTests

Feature started implementation for unit tests
This commit is contained in:
Rhyne 2017-12-04 07:34:36 -05:00 committed by GitHub
commit 942d56dc4b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
26 changed files with 15819 additions and 3 deletions

3
.gitignore vendored
View file

@ -1,3 +1,4 @@
/node_modules
npm-debug.log
/dist
/dist
/tests/node_modules

27
.travis.yml Normal file
View file

@ -0,0 +1,27 @@
language: node_js
node_js: "8.8.1"
notifications:
slack:
rooms:
- papercss:1MrmPTVH6FLA95Oa5IfXl7xQ#travis
addons:
firefox: latest
apt:
sources:
- google-chrome
packages:
- google-chrome-stable fluxbox
before_script:
- "sh -e /etc/init.d/xvfb start"
- sleep 3
- fluxbox >/dev/null 2>&1 &
- chmod +x ./jake.sh
- chmod +x ./tests/build/scripts/run_jake.sh
- export DISPLAY=:99.0
- npm install karma-firefox-launcher
- node node_modules/gulp/bin/gulp.js build
script: "./jake.sh loose=true capture=Firefox"

117
Jakefile.js Normal file
View file

@ -0,0 +1,117 @@
// Copyright (c) 2012-2014 Titanium I.T. LLC. All rights reserved. See LICENSE.txt for details.
// Main build file. Contains all tasks needed for normal development.
// There's no Quixote-specific configuration in this file.
(function() {
"use strict";
var startTime = Date.now();
var shell = require("shelljs");
var karma = require("simplebuild-karma");
var browserify = require("./tests/build/util/browserify_runner.js");
var browsers = require("./tests/build/config/tested_browsers.js");
var paths = require("./tests/build/config/paths.js");
var KARMA_CONFIG = "./tests/build/config/karma.conf.js";
var strict = !process.env.loose;
//*** GENERAL
desc("Lint and test");
task("default", [ "lint", "test" ], function() {
var elapsedSeconds = (Date.now() - startTime) / 1000;
console.log("\n\nBUILD OK (" + elapsedSeconds.toFixed(2) + "s)");
});
desc("Start server (for manual testing)");
task("run", [ "build" ], function() {
jake.exec("node ../node_modules/http-server/bin/http-server " + paths.clientDistDir, { interactive: true }, complete);
}, { async: true });
desc("Delete generated files");
task("clean", function() {
shell.rm("-rf", paths.generatedDir);
});
//*** LINT
/** */
desc("Lint everything");
task("lint", ["lintNode", "lintClient"]);
task("lintNode", function() {
process.stdout.write("Linting Node.js code: ");
}, { async: false });
task("lintClient", function() {
process.stdout.write("Linting browser code: ");
}, { async: false });
//*** TEST
desc("Start Karma server -- run this first");
task("karma", function() {
karma.start({
configFile: KARMA_CONFIG
}, complete, fail);
}, { async: true });
desc("Run tests");
task("test", function() {
console.log("Testing browser code: ");
var browsersToCapture = process.env.capture ? process.env.capture.split(",") : [];
karma.run({
configFile: KARMA_CONFIG,
expectedBrowsers: browsers,
strict: strict,
capture: browsersToCapture
}, complete, fail);
}, { async: true });
//*** BUILD
desc("Build distribution package");
task("build", [ "prepDistDir", "buildClient" ]);
task("prepDistDir", function() {
shell.rm("-rf", paths.distDir);
});
task("buildClient", [ paths.clientDistDir, "bundleClientJs" ], function() {
console.log("Copying client code: .");
shell.cp(
paths.clientDir + "/*.html",
paths.clientDir + "/*.css",
paths.clientDir + "/*.svg",
paths.clientDistDir
);
});
task("bundleClientJs", [ paths.clientDistDir ], function() {
console.log("Bundling browser code with Browserify: .");
browserify.bundle({
entry: paths.clientEntryPoint,
outfile: paths.clientDistBundle,
options: {
standalone: "toggle",
debug: true
}
}, complete, fail);
}, { async: true });
//*** CREATE DIRECTORIES
directory(paths.testDir);
directory(paths.clientDistDir);
}());

View file

@ -1,6 +1,8 @@
# PaperCSS
### The Less Formal CSS Framework
[![Build Status](https://travis-ci.org/papercss/papercss.svg?branch=master)](https://travis-ci.org/papercss/papercss)
## Demo & Docs
View the demo & docs at [getpapercss.com](https://www.getpapercss.com)

View file

@ -679,7 +679,7 @@ function add(x, y) {
&lt;button popover-top="Popover on top"&gt;Popover on top and on a button!&lt;/button&gt;</pre>
</div>
</div>
<div id="cards" class="section">
<h2>Cards</h2>
<h4>Full card example</h4>
@ -1197,7 +1197,7 @@ function add(x, y) {
<div id="article" class="section">
<h2>Article</h2>
<article class="article">
<h1 class="article-title"><a href="">Article Title</a></h1>
<p class="article-meta">Written by <a href="#">Super User</a> on 24 November 2017. Posted in <a href="#">Blog</a></p>

1
jake.bat Normal file
View file

@ -0,0 +1 @@
@call tests\build\scripts\run_jake -f tests\build\scripts\build.Jakefile.js %*

2
jake.sh Normal file
View file

@ -0,0 +1,2 @@
#!/bin/sh
. tests/build/scripts/run_jake.sh -f tests/build/scripts/build.Jakefile.js $*

View file

@ -19,6 +19,8 @@
},
"homepage": "https://github.com/rhyneav/papercss#readme",
"devDependencies": {
"browserify": "^14.1.0",
"chai": "^4.1.2",
"gulp": "3.9.1",
"gulp-clean-css": "3.9.0",
"gulp-connect": "5.0.0",
@ -26,10 +28,33 @@
"gulp-plumber": "1.1.0",
"gulp-rename": "1.2.2",
"gulp-watch-less": "1.0.1",
"http-server": "^0.9.0",
"install": "0.10.1",
"jake": "^8.0.15",
"jshint": "^2.9.4",
"karma": "^1.7.1",
"karma-chai": "^0.1.0",
"karma-commonjs": "1.0.0",
"karma-firefox-launcher": "^1.0.0",
"karma-mocha": "^1.3.0",
"karma-node-modules-middleware": "^1.0.1",
"karma-quixote": "^1.0.0",
"karma-requirejs": "^1.1.0",
"less": "2.7.2",
"mocha": "^4.0.1",
"nodemon": "^1.11.0",
"normalize.css": "7.0.0",
"npm": "5.3.0",
"object-merge": "^2.5.1",
"os": "^0.1.1",
"procfile": "^0.1.1",
"quixote": "^0.14.0",
"request": "^2.83.0",
"requirejs": "^2.3.5",
"semver": "^5.3.0",
"shelljs": "^0.7.6",
"simplebuild-jshint": "^1.3.0",
"simplebuild-karma": "^1.0.0",
"webpack-dev-server": "2.7.1"
}
}

View file

@ -0,0 +1,17 @@
// Copyright (c) 2012 Titanium I.T. LLC. All rights reserved. See LICENSE.txt for details.
// A cross-platform mechanism for determining how to run the build.
(function() {
"use strict";
var UNIX_BUILD_COMMAND = "./jake.sh";
var WINDOWS_BUILD_COMMAND = "jake.bat";
var os = require("os");
exports.get = function() {
return os.platform() === "win32" ? WINDOWS_BUILD_COMMAND : UNIX_BUILD_COMMAND;
//return WINDOWS_BUILD_COMMAND;
};
}());

View file

@ -0,0 +1,79 @@
// Karma configuration
// Quixote-specific configuration starts with "QUIXOTE:"
(function() {
"use strict";
var paths = require("./paths.js");
module.exports = function(config) {
config.set({
// base path, that will be used to resolve files and exclude
basePath: '../../..',
// frameworks to use
frameworks: ['mocha', 'commonjs'],
middleware: ['node-modules'],
// list of files / patterns to load in the browser
files: [
'tests/*.js',
'tests/vendor/*.js',
"node_modules/chai/chai.js",
//'tests/**/*.js',
//'node_modules/**/*.js',
//'node_modules/**/*.js',
// QUIXOTE: Serve the CSS file so we can load it in our tests
// Mark it `included: false` so Karma doesn't load it automatically
{ pattern: 'dist/paper.css', included: false }
],
// list of files to exclude
exclude: [],
// preprocess matching files before serving them to the browser
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
preprocessors: {
'tests/*.js': ['commonjs'],
'tests/vendor/*.js': ['commonjs'],
},
// test results reporter to use
// possible values: 'dots', 'progress', 'junit', 'growl', 'coverage'
reporters: ['dots'],
// web server port
port: 9876,
// enable / disable colors in the output (reporters and logs)
colors: true,
// level of logging
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
logLevel: config.LOG_INFO,
// enable / disable watching file and executing tests whenever any file changes
autoWatch: false,
// Start these browsers, currently available:
// - Chrome
// - ChromeCanary
// - Firefox
// - Opera
// - Safari (only Mac)
// - PhantomJS
// - IE (only Windows)
browsers: [],
// If browser does not capture in given timeout [ms], kill it
captureTimeout: 60000,
// Continuous Integration mode
// if true, it capture browsers, run tests and exit
singleRun: false
});
};
}());

View file

@ -0,0 +1,20 @@
// Copyright (c) 2015 Titanium I.T. LLC. All rights reserved. For license, see "README" or "LICENSE" file.
// Lists commonly-used directories. They're all relative to the project root.
(function() {
"use strict";
module.exports = {
generatedDir: "generated",
testDir: "generated/test",
distDir: "generated/dist",
clientDistDir: "generated/dist/client",
buildDir: "build",
clientDir: "src",
clientEntryPoint: "src/toggle.js",
clientDistBundle: "generated/dist/client/bundle.js"
};
}());

View file

@ -0,0 +1,17 @@
// Copyright (c) 2014 Titanium I.T. LLC. All rights reserved. For license, see "README" or "LICENSE" file.
(function() {
"use strict";
// Uncomment and modify the following list to cause the build to fail unless these browsers are tested.
// There's no Quixote-specific configuration in this file.
module.exports = [
//"IE 10.0.0 (Windows 7 0.0.0)",
//"Firefox 41.0.0 (Mac OS X 10.10.0)",
//"Chrome 46.0.2490 (Mac OS X 10.10.5)",
//"Safari 9.0.1 (Mac OS X 10.10.5)",
//"Mobile Safari 8.0.0 (iOS 8.4.0)",
//"Chrome Mobile 44.0.2403 (Android 6.0.0)"
];
}());

View file

@ -0,0 +1,117 @@
// Copyright (c) 2012-2014 Titanium I.T. LLC. All rights reserved. See LICENSE.txt for details.
// Main build file. Contains all tasks needed for normal development.
// There's no Quixote-specific configuration in this file.
(function() {
"use strict";
var startTime = Date.now();
var shell = require("../../../node_modules/shelljs/shell.js");
var karma = require("simplebuild-karma");
var browserify = require("../util/browserify_runner.js");
var browsers = require("../config/tested_browsers.js");
var paths = require("../config/paths.js");
var KARMA_CONFIG = "./tests/build/config/karma.conf.js";
var strict = !process.env.loose;
//*** GENERAL
desc("Lint and test");
task("default", [ "lint", "test" ], function() {
var elapsedSeconds = (Date.now() - startTime) / 1000;
console.log("\n\nBUILD OK (" + elapsedSeconds.toFixed(2) + "s)");
});
desc("Start server (for manual testing)");
task("run", [ "build" ], function() {
jake.exec("node ../node_modules/http-server/bin/http-server " + paths.clientDistDir, { interactive: true }, complete);
}, { async: true });
desc("Delete generated files");
task("clean", function() {
shell.rm("-rf", paths.generatedDir);
});
//*** LINT
/** */
desc("Lint everything");
task("lint", ["lintNode", "lintClient"]);
task("lintNode", function() {
process.stdout.write("Linting Node.js code: ");
}, { async: false });
task("lintClient", function() {
process.stdout.write("Linting browser code: ");
}, { async: false });
//*** TEST
desc("Start Karma server -- run this first");
task("karma", function() {
karma.start({
configFile: KARMA_CONFIG
}, complete, fail);
}, { async: true });
desc("Run tests");
task("test", function() {
console.log("Testing browser code: ");
var browsersToCapture = process.env.capture ? process.env.capture.split(",") : [];
karma.run({
configFile: KARMA_CONFIG,
expectedBrowsers: browsers,
strict: strict,
capture: browsersToCapture
}, complete, fail);
}, { async: true });
//*** BUILD
desc("Build distribution package");
task("build", [ "prepDistDir", "buildClient" ]);
task("prepDistDir", function() {
shell.rm("-rf", paths.distDir);
});
task("buildClient", [ paths.clientDistDir, "bundleClientJs" ], function() {
console.log("Copying client code: .");
shell.cp(
paths.clientDir + "/*.html",
paths.clientDir + "/*.css",
paths.clientDir + "/*.svg",
paths.clientDistDir
);
});
task("bundleClientJs", [ paths.clientDistDir ], function() {
console.log("Bundling browser code with Browserify: .");
browserify.bundle({
entry: paths.clientEntryPoint,
outfile: paths.clientDistBundle,
options: {
standalone: "toggle",
debug: true
}
}, complete, fail);
}, { async: true });
//*** CREATE DIRECTORIES
directory(paths.testDir);
directory(paths.clientDistDir);
}());

View file

@ -0,0 +1,117 @@
// Copyright (c) 2012-2014 Titanium I.T. LLC. All rights reserved. See LICENSE.txt for details.
// Main build file. Contains all tasks needed for normal development.
// There's no Quixote-specific configuration in this file.
(function() {
"use strict";
var startTime = Date.now();
var shell = require("../../../node_modules/shelljs/shell.js");
var karma = require("simplebuild-karma");
var browserify = require("../util/browserify_runner.js");
var browsers = require("../config/tested_browsers.js");
var paths = require("../config/paths.js");
var KARMA_CONFIG = "./tests/build/config/karma.conf.js";
var strict = !process.env.loose;
//*** GENERAL
desc("Lint and test");
task("default", [ "lint", "test" ], function() {
var elapsedSeconds = (Date.now() - startTime) / 1000;
console.log("\n\nBUILD OK (" + elapsedSeconds.toFixed(2) + "s)");
});
desc("Start server (for manual testing)");
task("run", [ "build" ], function() {
jake.exec("node ../node_modules/http-server/bin/http-server " + paths.clientDistDir, { interactive: true }, complete);
}, { async: true });
desc("Delete generated files");
task("clean", function() {
shell.rm("-rf", paths.generatedDir);
});
//*** LINT
/** */
desc("Lint everything");
task("lint", ["lintNode", "lintClient"]);
task("lintNode", function() {
process.stdout.write("Linting Node.js code: ");
}, { async: false });
task("lintClient", function() {
process.stdout.write("Linting browser code: ");
}, { async: false });
//*** TEST
desc("Start Karma server -- run this first");
task("karma", function() {
karma.start({
configFile: KARMA_CONFIG
}, complete, fail);
}, { async: true });
desc("Run tests");
task("test", function() {
console.log("Testing browser code: ");
var browsersToCapture = process.env.capture ? process.env.capture.split(",") : [];
karma.run({
configFile: KARMA_CONFIG,
expectedBrowsers: browsers,
strict: strict,
capture: browsersToCapture
}, complete, fail);
}, { async: true });
//*** BUILD
desc("Build distribution package");
task("build", [ "prepDistDir", "buildClient" ]);
task("prepDistDir", function() {
shell.rm("-rf", paths.distDir);
});
task("buildClient", [ paths.clientDistDir, "bundleClientJs" ], function() {
console.log("Copying client code: .");
shell.cp(
paths.clientDir + "/*.html",
paths.clientDir + "/*.css",
paths.clientDir + "/*.svg",
paths.clientDistDir
);
});
task("bundleClientJs", [ paths.clientDistDir ], function() {
console.log("Bundling browser code with Browserify: .");
browserify.bundle({
entry: paths.clientEntryPoint,
outfile: paths.clientDistBundle,
options: {
standalone: "toggle",
debug: true
}
}, complete, fail);
}, { async: true });
//*** CREATE DIRECTORIES
directory(paths.testDir);
directory(paths.clientDistDir);
}());

View file

@ -0,0 +1,7 @@
@echo off
REM Runs Jake from node_modules directory, preventing it from needing to be installed globally
REM Also ensures node modules have been installed
REM There's no Quixote-specific configuration in this file.
if not exist node_modules\.bin\jake.cmd call npm install
node_modules\.bin\jake %*

View file

@ -0,0 +1,6 @@
# Runs Jake from node_modules directory, preventing it from needing to be installed globally
# Also ensures node modules have been installed
# There's no Quixote-specific configuration in this file.
[ ! -f node_modules/.bin/jake ] && echo "Installing npm modules:" && npm install
node_modules/.bin/jake $*

View file

@ -0,0 +1,28 @@
// Copyright (c) 2015 Titanium I.T. LLC. All rights reserved. For license, see "README" or "LICENSE" file.
// Automatically runs build when files change.
// There's no Quixote-specific configuration in this file.
(function() {
"use strict";
var nodemon = require("nodemon");
var buildCommand = require("../config/build_command.js");
var paths = require("../config/paths.js");
console.log("*** Using nodemon to run " + buildCommand.get() + ". Type 'rs<enter>' to force restart.");
nodemon({
ext: "sh bat json js html css",
ignore: paths.generatedDir,
exec: buildCommand.get() + " " + process.argv.slice(2).join(" "),
execMap: {
sh: "/bin/sh",
bat: "cmd.exe /c",
cmd: "cmd.exe /c"
}
}).on("restart", function(files) {
if (files) console.log("*** Restarting due to", files);
else console.log("*** Restarting");
});
}());

View file

@ -0,0 +1,21 @@
/* Copyright (c) 2014 Titanium I.T. LLC - See LICENSE.txt for license */
// Helper function for running Browserify
// There's no Quixote-specific configuration in this file.
"use strict";
var fs = require("fs");
var path = require("path");
var browserify = require("browserify");
exports.bundle = function(config, success, failure) {
var b = browserify(config.options);
b.add(path.resolve(config.entry));
b.bundle(function(err, bundle) {
if (err) return failure(err);
fs.writeFileSync(config.outfile, bundle);
return success();
});
};

View file

@ -0,0 +1,76 @@
// Copyright (c) 2012-2015 Titanium I.T. LLC. All rights reserved. See LICENSE.txt for details.
// Helper functions for running Karma
// There's no Quixote-specific configuration in this file.
(function() {
"use strict";
var path = require("path");
var sh = require("./sh.js");
var runner = require("karma/lib/runner");
var server = require("karma/lib/server");
var KARMA = "node node_modules/karma/bin/karma";
exports.serve = function(configFile, success, fail) {
var command = KARMA + " start " + configFile;
sh.run(command, success, function () {
fail("Could not start Karma server");
});
};
exports.runTests = function(options, success, fail) {
options.capture = options.capture || [];
var config = {
configFile: path.resolve(options.configFile),
browsers: options.capture,
singleRun: options.capture.length > 0
};
var runKarma = runner.run.bind(runner);
if (config.singleRun) runKarma = server.start.bind(server);
var stdout = new CapturedStdout();
runKarma(config, function(exitCode) {
stdout.restore();
if (exitCode) return fail("Client tests failed (did you start the Karma server?)");
var browserMissing = checkRequiredBrowsers(options.browsers, stdout);
if (browserMissing && options.strict) return fail("Did not test all browsers");
if (stdout.capturedOutput.indexOf("TOTAL: 0 SUCCESS") !== -1) return fail("No tests were run!");
return success();
});
};
function checkRequiredBrowsers(requiredBrowsers, stdout) {
var browserMissing = false;
requiredBrowsers.forEach(function(browser) {
browserMissing = lookForBrowser(browser, stdout.capturedOutput) || browserMissing;
});
return browserMissing;
}
function lookForBrowser(browser, output) {
var missing = output.indexOf(browser + ": Executed") === -1;
if (missing) console.log("Warning: " + browser + " was not tested!");
return missing;
}
function CapturedStdout() {
var self = this;
self.oldStdout = process.stdout.write;
self.capturedOutput = "";
process.stdout.write = function(data) {
self.capturedOutput += data;
self.oldStdout.apply(this, arguments);
};
}
CapturedStdout.prototype.restore = function() {
process.stdout.write = this.oldStdout;
};
}());

View file

@ -0,0 +1,54 @@
// Copyright (c) 2014-2015 Titanium I.T. LLC. All rights reserved. See LICENSE.txt for details.
// Helper function for running Mocha
// There's no Quixote-specific configuration in this file.
(function() {
"use strict";
var Mocha = require("mocha");
var jake = require("jake");
exports.runTests = function runTests(options, success, failure) {
var mocha = new Mocha(options.options);
var files = deglob(options.files);
files.forEach(mocha.addFile.bind(mocha));
// This is a bit of a hack. The issue is this: during test execution, if an exception is thrown inside
// of a callback (and keep in mind that assertions throw exceptions), there's no way for Mocha to catch
// that exception.
// So Mocha registers an 'uncaughtException' handler on Node's process object. That way any unhandled
// exception is passed to Mocha.
// The problem is that Jake ALSO listens for 'uncaughtException'. Its handler and Mocha's handler don't
// get along. Somehow the Jake handler seems to terminate Mocha's test run... not sure why. We need to
// disable Jake's handler while Mocha is running.
// This code disables ALL uncaughtException handlers and then restores them after Mocha is done. It's
// very hacky and likely to cause problems in certain edge cases (for example, '.once' listeners aren't
// restored properly), but it seems to be working for now.
// It might be possible to create a better solution by using Node's 'domain' module. Something to look
// into if you're reading this. Another solution is to just spawn Mocha in a separate process, but I
// didn't want the time penalty involved. Besides, this seems to be working okay.
var savedListeners = disableExceptionListeners();
var runner = mocha.run(function(failures) {
restoreExceptionListeners(savedListeners);
if (failures) return failure("Tests failed");
else return success();
});
};
function deglob(globs) {
return new jake.FileList(globs).toArray();
}
function disableExceptionListeners() {
var listeners = process.listeners("uncaughtException");
process.removeAllListeners("uncaughtException");
return listeners;
}
function restoreExceptionListeners(listeners) {
listeners.forEach(process.addListener.bind(process, "uncaughtException"));
}
}());

48
tests/build/util/sh.js Normal file
View file

@ -0,0 +1,48 @@
// Copyright (c) 2012-2015 Titanium I.T. LLC. All rights reserved. See LICENSE.txt for details.
// Helper functions for running processes.
// There's no Quixote-specific configuration in this file.
(function() {
"use strict";
var jake = require("jake");
exports.runMany = function(commands, successCallback, failureCallback) {
var stdout = [];
function serializedSh(command) {
if (command) {
run(command, function(oneStdout) {
stdout.push(oneStdout);
serializedSh(commands.shift());
}, failureCallback);
}
else {
successCallback(stdout);
}
}
serializedSh(commands.shift());
};
var run = exports.run = function(oneCommand, successCallback, failureCallback) {
var stdout = "";
var child = jake.createExec(oneCommand);
child.on("stdout", function(data) {
process.stdout.write(data);
stdout += data;
});
child.on("stderr", function(data) {
process.stderr.write(data);
});
child.on("cmdEnd", function() {
successCallback(stdout);
});
child.on("error", function() {
failureCallback(stdout);
});
console.log("> " + oneCommand);
child.run();
};
}());

View file

@ -0,0 +1,29 @@
// Copyright (c) 2013 Titanium I.T. LLC. All rights reserved. See LICENSE.TXT for details.
// Helper function for checking version numbers.
// There's no Quixote-specific configuration in this file.
(function() {
"use strict";
var semver = require("semver");
exports.check = function(options, success, fail) {
if (options.strict) {
if (semver.neq(options.actual, options.expected)) return failWithQualifier("exactly");
}
else {
if (semver.lt(options.actual, options.expected)) return failWithQualifier("at least");
if (semver.neq(options.actual, options.expected)) console.log("Warning: Newer " + options.name +
" version than expected. Expected " + options.expected + ", but was " + options.actual + ".");
}
return success();
function failWithQualifier(qualifier) {
return fail("Incorrect " + options.name + " version. Expected " + qualifier +
" " + options.expected + ", but was " + options.actual + ".");
}
};
}());

75
tests/colors.js Normal file
View file

@ -0,0 +1,75 @@
(function() {
"use strict";
var quixote = require("./vendor/quixote.js");
var assert = require("./vendor/chai.js").assert;
describe("Colors", function() {
var frame;
var media;
var textPrimary;
var textSecondary;
var textSuccess;
var textWarning;
var textDanger;
var textMuted;
before(function(done) {
frame = quixote.createFrame({
stylesheet: "/base/dist/paper.css"
}, done);
});
after(function() {
frame.remove();
});
beforeEach(function() {
frame.reset();
media = frame.add(
"<div class='media'>" +
"<p class='text-primary' id='textPrimary'>text-primary</p>" +
"<p class='text-secondary' id='textSecondary'>text-secondary</p>" +
"<p class='text-success' id='textSuccess'>text-success</p>" +
"<p class='text-warning' id='textWarning'>text-warning</p>" +
"<p class='text-danger' id='textDanger'>text-danger</p>" +
"<p class='text-muted' id='textMuted'>text-muted</p>" +
"</div>",
"colors"
);
textPrimary = frame.get("#textPrimary");
textSecondary = frame.get("#textSecondary");
textSuccess = frame.get("#textSuccess");
textWarning = frame.get("#textWarning");
textDanger = frame.get("#textDanger");
textMuted = frame.get("#textMuted");
});
it("Text color is set to primary", function() {
assert.equal(textPrimary.getRawStyle("color"), "rgb(65, 64, 62)", "Primary color should be #41403E");
});
it("Text color is set to secondary", function() {
assert.equal(textSecondary.getRawStyle("color"), "rgb(0, 113, 222)", "Secondary color should be #0071DE");
});
it("Text color is set to success", function() {
assert.equal(textSuccess.getRawStyle("color"), "rgb(134, 163, 97)", "Success color should be #86a361");
});
it("Text color is set to warning", function() {
assert.equal(textWarning.getRawStyle("color"), "rgb(221, 205, 69)", "Warning color should be #ddcd45");
});
it("Text color is set to danger", function() {
assert.equal(textDanger.getRawStyle("color"), "rgb(167, 52, 45)", "Danger color should be #a7342d");
});
it("Text color is set to muted", function() {
assert.equal(textMuted.getRawStyle("color"), "rgb(134, 142, 150)", "Muted color should be #868e96");
});
});
}());

28
tests/index.html Normal file
View file

@ -0,0 +1,28 @@
<!DOCTYPE html>
<html>
<!-- smoke test marker: automatopia home page -->
<head>
<title>Agile Engineering for the Web</title>
<link rel="stylesheet" type="text/css" href="./screen.css">
<script src="bundle.js" type="text/javascript"></script>
</head>
<body>
<!-- Note: This page is for manual demonstration of the example code. It's not tested like real production code should be. -->
<div class="media">
<img id="image" class="media__figure" src="icon.svg" width="25" />
<p id="content" class="media__body invisible">Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem.</p>
</div>
<script type="text/javascript">
document.addEventListener("DOMContentLoaded", function(event) {
var image = document.getElementById("image");
var content = document.getElementById("content");
toggle.init(image, content, "invisible");
});
</script>
</body>
</html>

10707
tests/vendor/chai.js vendored Normal file

File diff suppressed because it is too large Load diff

4195
tests/vendor/quixote.js vendored Normal file

File diff suppressed because one or more lines are too long