Permalink
Browse files

use mocha for test runner

still brokenish
  • Loading branch information...
1 parent 5813a54 commit 5a608755b804ca2aae54f8451fec005f9ba38d94 @tj committed Apr 3, 2012
View
@@ -1,6 +1,9 @@
test:
- @node test/runner.js test/cases/*.styl
+ @./node_modules/.bin/mocha \
+ --require should \
+ --ignore-leaks \
+ test/runner.js
test-server:
@node test/server.js
View
@@ -10,6 +10,8 @@
"connect": "1.x"
, "jade": "0.22.0"
, "stylus": "0.19.x"
+ , "mocha": "*"
+ , "should": "*"
, "canvas": "*"
},
"author": "TJ Holowaychuk <tj@vision-media.ca>",
View
@@ -1,24 +1,33 @@
section {
display: -webkit-box;
display: -moz-box;
+ display: -o-box;
+ display: -ms-box;
display: box;
}
section {
display: -webkit-box;
display: -moz-box;
+ display: -o-box;
+ display: -ms-box;
display: box;
-webkit-box-orient: horizontal;
-moz-box-orient: horizontal;
+ -ms-box-orient: horizontal;
box-orient: horizontal;
}
section {
display: -webkit-box;
display: -moz-box;
+ display: -o-box;
+ display: -ms-box;
display: box;
-webkit-box-orient: horizontal;
-moz-box-orient: horizontal;
+ -ms-box-orient: horizontal;
box-orient: horizontal;
-webkit-box-direction: reverse;
-moz-box-direction: reverse;
+ -ms-box-direction: reverse;
box-direction: reverse;
}
@@ -2,24 +2,32 @@ body {
background: -webkit-gradient(linear, left top, left bottom, color-stop(0, #fff), color-stop(1, #000));
background: -webkit-linear-gradient(top, #fff 0%, #000 100%);
background: -moz-linear-gradient(top, #fff 0%, #000 100%);
+ background: -o-linear-gradient(top, #fff 0%, #000 100%);
+ background: -ms-linear-gradient(top, #fff 0%, #000 100%);
background: linear-gradient(top, #fff 0%, #000 100%);
}
body {
background: -webkit-gradient(linear, left top, right bottom, color-stop(0, #fff), color-stop(0.25, #f00), color-stop(0.5, #00f), color-stop(1, #000));
background: -webkit-linear-gradient(top left, #fff 0%, #f00 25%, #00f 50%, #000 100%);
background: -moz-linear-gradient(top left, #fff 0%, #f00 25%, #00f 50%, #000 100%);
+ background: -o-linear-gradient(top left, #fff 0%, #f00 25%, #00f 50%, #000 100%);
+ background: -ms-linear-gradient(top left, #fff 0%, #f00 25%, #00f 50%, #000 100%);
background: linear-gradient(top left, #fff 0%, #f00 25%, #00f 50%, #000 100%);
}
body {
background: -webkit-gradient(linear, right bottom, left top, color-stop(0, #fff), color-stop(0.8, #000));
background: -webkit-linear-gradient(bottom right, #fff 0%, #000 80%);
background: -moz-linear-gradient(bottom right, #fff 0%, #000 80%);
+ background: -o-linear-gradient(bottom right, #fff 0%, #000 80%);
+ background: -ms-linear-gradient(bottom right, #fff 0%, #000 80%);
background: linear-gradient(bottom right, #fff 0%, #000 80%);
}
body {
background: -webkit-gradient(linear, right bottom, left top, color-stop(0, #fff), color-stop(0.8, #000));
background: -webkit-linear-gradient(right bottom, #fff 0%, #000 80%);
background: -moz-linear-gradient(right bottom, #fff 0%, #000 80%);
+ background: -o-linear-gradient(right bottom, #fff 0%, #000 80%);
+ background: -ms-linear-gradient(right bottom, #fff 0%, #000 80%);
background: linear-gradient(right bottom, #fff 0%, #000 80%);
}
body {
@@ -6,11 +6,15 @@ button {
button {
-moz-border-radius-topleft: 10px;
-webkit-border-top-left-radius: 10px;
+ -o-border-top-left-radius: 10px;
+ -ms-border-top-left-radius: 10px;
border-top-left-radius: 10px;
}
button {
-moz-border-radius-bottomright: 5px;
-webkit-border-bottom-right-radius: 5px;
+ -o-border-bottom-right-radius: 5px;
+ -ms-border-bottom-right-radius: 5px;
border-bottom-right-radius: 5px;
}
button {
@@ -10,6 +10,8 @@ button
button
border-radius: bottom right 5px
+vendor-prefixes = webkit moz official
+
button
border-radius: top left 5px bottom right 10px
View
@@ -119,45 +119,38 @@ section {
column-gap: 2em;
}
button {
- -o-transition: all 0.1s ease-in-out 1s;
+ -webkit-transition: all 0.1s ease-in-out 1s;
-webkit-transition: all 0.1s ease-in-out 1s;
-moz-transition: all 0.1s ease-in-out 1s;
transition: all 0.1s ease-in-out 1s;
-webkit-backface-visibility: hidden;
backface-visibility: hidden;
}
button {
- -o-transition-property: all;
-webkit-transition-property: all;
-moz-transition-property: all;
transition-property: all;
- -o-transition-duration: 0.1s;
-webkit-transition-duration: 0.1s;
-moz-transition-duration: 0.1s;
transition-duration: 0.1s;
- -o-transition-timing-function: ease-in-out;
-webkit-transition-timing-function: ease-in-out;
-moz-transition-timing-function: ease-in-out;
transition-timing-function: ease-in-out;
- -o-transition-delay: 1s;
-webkit-transition-delay: 1s;
-moz-transition-delay: 1s;
transition-delay: 1s;
}
button {
- -o-transform: rotateY(45deg);
-webkit-transform: rotateY(45deg);
-moz-transform: rotateY(45deg);
transform: rotateY(45deg);
}
section {
- -o-border-image: url("image.png") 20% stretch stretch;
-webkit-border-image: url("image.png") 20% stretch stretch;
-moz-border-image: url("image.png") 20% stretch stretch;
border-image: url("image.png") 20% stretch stretch;
}
p {
- -o-hyphens: auto;
-webkit-hyphens: auto;
-moz-hyphens: auto;
hyphens: auto;
View
@@ -1,6 +1,8 @@
@import 'nib/vendor'
+vendor-prefixes = webkit moz official
+
button
box-shadow: 1px 1px 5px #eee
View
@@ -4,153 +4,36 @@
*/
var stylus = require('stylus')
- , basename = require('path').basename
, nib = require('../')
, fs = require('fs');
-/**
- * Test count.
- */
-
-var count = 0;
-
-/**
- * Failure count.
- */
-
-var failures = 0;
-
-console.log();
-
-/**
- * Test the given `test`.
- *
- * @param {String} test
- * @param {Function} fn
- */
+// test cases
-function test(test, fn) {
- var base = __dirname + '/cases/' + test
- , path = base + '.styl'
- , csspath = base + '.css';
+var cases = fs.readdirSync('test/cases').filter(function(file){
+ return ~file.indexOf('.styl');
+}).map(function(file){
+ return file.replace('.styl', '');
+});
- fs.readFile(path, 'utf8', function(err, str){
- if (err) throw err;
+describe('integration', function(){
+ cases.forEach(function(test){
+ var name = test.replace(/[-.]/g, ' ');
+ it(name, function(){
+ var path = 'test/cases/' + test + '.styl';
+ var styl = fs.readFileSync(path, 'utf8').replace(/\r/g, '');
+ var css = fs.readFileSync('test/cases/' + test + '.css', 'utf8').replace(/\r/g, '').trim();
- var style = stylus(str)
- .use(nib())
- .set('filename', path)
- .include(__dirname + '/images')
- .include(__dirname + '/cases/import.basic');
+ var style = stylus(styl)
+ .use(nib())
+ .set('filename', path)
+ .define('url', stylus.url());
- if (~test.indexOf('compress')) style.set('compress', true);
+ if (~test.indexOf('compress')) style.set('compress', true);
- style.render(function(err, actual){
- if (err) throw err;
- fs.readFile(csspath, 'utf8', function(err, expected){
+ style.render(function(err, actual){
if (err) throw err;
- expected += '\n';
- if (actual == expected) {
- fn();
- } else {
- fn(actual, expected);
- }
+ actual.trim().should.equal(css);
});
- });
- });
- return test;
-};
-
-/**
- * Auto-load and run tests.
- */
-
-fs.readdir(__dirname + '/cases', function(err, files){
- if (err) throw err;
- var tests = []
- , curr;
-
- files.forEach(function(file){
- if (/\.styl$/.test(file)) {
- ++count;
- tests.push(basename(file, '.styl'));
- }
+ })
});
-
- (function next() {
- curr = tests.shift();
- if (!curr) return done();
- process.stderr.write(' \033[90m' + curr + '\033[0m');
- test(curr, function(actual, expected){
- if (actual) {
- ++failures;
- console.error('\r \033[31m✖\033[0m \033[90m' + curr + '\033[0m\n');
- diff(actual, expected);
- console.error();
- } else {
- console.error('\r \033[36m✔\033[0m \033[90m' + curr + '\033[0m');
- }
- next();
- });
- })();
-});
-
-/**
- * Diff `actual` / `expected`.
- *
- * @param {String} actual
- * @param {String} expected
- */
-
-function diff(actual, expected) {
- var actual = actual.split('\n')
- , expected = expected.split('\n')
- , len = largestLineIn(expected);
-
- console.error(' expected');
- expected.forEach(function(line, i){
- var other = actual[i]
- , pad = len - line.length
- , pad = Array(++pad).join(' ')
- , same = line == other;
- if (same) {
- console.error(' %d| %j%s | %j', i+1, line, pad, other);
- } else {
- console.error(' \033[31m%d| %j%s | %j\033[0m', i+1, line, pad, other);
- }
- });
-}
-
-/**
- * Return the length of the largest line in `lines`.
- *
- * @param {Array} lines
- * @return {Number}
- */
-
-function largestLineIn(lines) {
- return lines.reduce(function(n, line){
- return Math.max(n, line.length);
- }, 0);
-}
-
-/**
- * Done!!!
- */
-
-function done() {
- console.log();
- console.log(
- ' \033[90mcompleted\033[0m'
- + ' \033[32m%d\033[0m'
- + ' \033[90mtests\033[0m', count);
-
- if (failures) {
- console.error(' \033[90mfailed\033[0m'
- + ' \033[31m%d\033[0m'
- + ' \033[90mtests\033[0m', failures);
- process.exit(failures);
- }
-
- console.log();
-}
+})

0 comments on commit 5a60875

Please sign in to comment.