Skip to content
Permalink
Browse files

tests start emerging!

  • Loading branch information...
bevacqua committed Nov 23, 2014
1 parent ee3ff6e commit 34f586765867604d3bc36fedd5568dbc6a50cd93
@@ -0,0 +1,7 @@
language: node_js

node_js:
- 0.10

script:
- npm test
@@ -1,4 +1,4 @@
[![taunus.png][3]][1]
[![taunus.png][3]][1] [![Build Status](https://secure.travis-ci.org/taunus/taunus.png?branch=master)](https://travis-ci.org/taunus/taunus)

> Micro Isomorphic MVC. Progressive Enhancement. Content-First. Single-Page Applications (that are also server-side rendered). Predictive Caching. Bring Your Own View Engine.
@@ -31,6 +31,14 @@ You can analyze the bundle size using the command below.
npm run diagnose
```

# Tests

Taunus has unit tests. Run them with `npm`.

```shell
npm test
```

# License

MIT
@@ -13,7 +13,7 @@ var cache = {};
function bro (file, done) {
var resolved = path.resolve(file);
if (resolved in cache) {
end(); return;
end(null); return;
}

fs.exists(resolved, work);
@@ -22,7 +22,7 @@ function bro (file, done) {
if (exists) {
contra.waterfall([browser, adjust, wrap], end);
} else {
cache[resolved] = null; end();
cache[resolved] = null; end(null);
}
}

@@ -30,4 +30,4 @@ function dotfile () {
}
}

module.exports = _.merge({}, defaults, manifest());
module.exports = _.assign({}, defaults, manifest());
@@ -21,7 +21,7 @@
},
"scripts": {
"lint": "jshint . --reporter node_modules/jshint-stylish/stylish.js",
"test": "npm run lint",
"test": "tape test/*/*.js",
"deploy": "npm version ${BUMP:-\"patch\"} --no-git-tag-version && cat package.json | jq .version > version.json && git add version.json package.json && git commit -m \"Taunus release v$(cat package.json | jq -r .version)\" && npm publish && git push",
"diagnose": "browserify . --full-paths | uglifyjs -m -c | discify --open & browserify . --full-paths | uglifyjs -m -c | gzip-size | pretty-bytes"
},
@@ -51,6 +51,8 @@
"jshint": "^2.5.0",
"jshint-stylish": "^0.2.0",
"pretty-bytes": "^1.0.1",
"proxyquire": "^1.1.0",
"tape": "^3.0.3",
"uglify-js": "^2.4.15"
}
}
Binary file not shown.

This file was deleted.

@@ -0,0 +1,12 @@
'use strict';

var test = require('tape');

test('negotiates content type', function (t) {
var accepts = require('../../lib/accepts');
t.equal(accepts({headers:{accept:'text/plain'}}), 'text');
t.equal(accepts({headers:{accept:'text/html'}}), 'html');
t.equal(accepts({headers:{accept:'*/*'}}), 'html');
t.equal(accepts({headers:{accept:'application/json'}}), 'json');
t.end();
});
@@ -0,0 +1,30 @@
'use strict';

var fs = require('fs');
var test = require('tape');
var proxyquire = require('proxyquire');

test('browserifies foo.js', function (t) {
var bro = require('../../lib/bro');

bro('./test/lib/fixture/foo.js', function (err, result) {
t.notOk(err, 'error should be falsy');
t.equal(result + '\n', read('./test/lib/fixture/foo.expect'));
t.end();
});
});

test('browserifies foo.js and minifies', function (t) {
var bro = proxyquire('../../lib/bro', {
'./state': { deferMinified: true }
});
bro('./test/lib/fixture/foo.js', function (err, result) {
t.notOk(err, 'error should be falsy');
t.equal(result + '\n', read('./test/lib/fixture/foo.expect.min'));
t.end();
});
});

function read (file) {
return fs.readFileSync(file, 'utf8');
}
@@ -0,0 +1,63 @@
'use strict';

var test = require('tape');
var actions = [
'home/index',
'home/about',
'admin/index',
'admin/nuke',
'admin/ban',
'admin/superuser',
'articles/one',
'articles/index',
'articles/all'
];
var cases = {
'defers all the things': {
rules: ['?'],
deferred: actions
},
'defer all the admins': {
rules: ['admin'],
deferred: actions.filter(function (a) { return a.indexOf('admin')===0;})
},
'defer all the index': {
rules: ['?/index'],
deferred: actions.filter(function (a) { return a.indexOf('index')!==-1;})
},
'defer nothing': {
rules: ['index'],
deferred: []
},
'defer nothing 2': {
rules: ['home/about/car'],
deferred: []
},
'defer only this one': {
rules: ['home/about'],
deferred: ['home/about']
},
'defer only this one 2': {
rules: ['home/index'],
deferred: ['home/index']
}
}

Object.keys(cases).forEach(function register (tc) {
test(tc, testCase);

function testCase (t) {
var deferred = require('../../lib/deferred');
cases[tc].deferred.forEach(function deferreds (action) {
t.ok(deferred(action, cases[tc].rules), action + ' is deferred');
});
actions.filter(undef).forEach(function undeferreds (action) {
t.notOk(deferred(action, cases[tc].rules), action + ' is not deferred');
});
t.end();
}

function undef (action) {
return cases[tc].deferred.indexOf(action) === -1;
}
});
@@ -0,0 +1,7 @@
(function(){return require=(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({"extract":[function(require,module,exports){
module.exports=function(){}

},{}]},{},[])
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIm5vZGVfbW9kdWxlcy9icm93c2VyaWZ5L25vZGVfbW9kdWxlcy9icm93c2VyLXBhY2svX3ByZWx1ZGUuanMiLCJ0ZXN0L2xpYi9maXh0dXJlL2Zvby5qcyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQTtBQ0FBO0FBQ0EiLCJmaWxlIjoiZ2VuZXJhdGVkLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXNDb250ZW50IjpbIihmdW5jdGlvbiBlKHQsbixyKXtmdW5jdGlvbiBzKG8sdSl7aWYoIW5bb10pe2lmKCF0W29dKXt2YXIgYT10eXBlb2YgcmVxdWlyZT09XCJmdW5jdGlvblwiJiZyZXF1aXJlO2lmKCF1JiZhKXJldHVybiBhKG8sITApO2lmKGkpcmV0dXJuIGkobywhMCk7dmFyIGY9bmV3IEVycm9yKFwiQ2Fubm90IGZpbmQgbW9kdWxlICdcIitvK1wiJ1wiKTt0aHJvdyBmLmNvZGU9XCJNT0RVTEVfTk9UX0ZPVU5EXCIsZn12YXIgbD1uW29dPXtleHBvcnRzOnt9fTt0W29dWzBdLmNhbGwobC5leHBvcnRzLGZ1bmN0aW9uKGUpe3ZhciBuPXRbb11bMV1bZV07cmV0dXJuIHMobj9uOmUpfSxsLGwuZXhwb3J0cyxlLHQsbixyKX1yZXR1cm4gbltvXS5leHBvcnRzfXZhciBpPXR5cGVvZiByZXF1aXJlPT1cImZ1bmN0aW9uXCImJnJlcXVpcmU7Zm9yKHZhciBvPTA7bzxyLmxlbmd0aDtvKyspcyhyW29dKTtyZXR1cm4gc30pIiwibW9kdWxlLmV4cG9ydHM9ZnVuY3Rpb24oKXt9XG4iXX0=

})()("extract")
@@ -0,0 +1,2 @@
(function(){return require=function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n?n:r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}({extract:[function(r,e){e.exports=function(){}},{}]},{},[]);
})()("extract")
@@ -0,0 +1 @@
module.exports=function(){}
@@ -0,0 +1,10 @@
'use strict';

var test = require('tape');

test('optionalRequire fails silently', function (t) {
var optionalRequire = require('../../lib/optionalRequire');
t.equal(optionalRequire('./foo'), null);
t.equal(optionalRequire('./fixture/foo'), require('./fixture/foo'));
t.end();
});

0 comments on commit 34f5867

Please sign in to comment.
You can’t perform that action at this time.