Skip to content

Commit

Permalink
[WO-307] add node support, activate unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Tankred Hase committed Apr 9, 2014
1 parent 556358e commit 79f8f81
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 16 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
language: node_js
node_js:
- "0.8"
- "0.10"
- "0.11"
before_install:
Expand Down
23 changes: 20 additions & 3 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,32 @@ module.exports = function(grunt) {
base: '.',
keepalive: true
}
},
test: {
options: {
port: 12346,
base: '.'
}
}
},

mocha_phantomjs: {
mochaTest: {
all: {
options: {
reporter: 'spec'
},
src: ['test/index.html']
src: ['test/*-unit.js']
}
},

mocha_phantomjs: {
all: {
options: {
reporter: 'spec',
urls: [
'http://localhost:12346/test/index.html'
]
}
}
}
});
Expand All @@ -38,5 +55,5 @@ module.exports = function(grunt) {

// Tasks
grunt.registerTask('dev', ['connect:dev']);
grunt.registerTask('default', ['jshint', 'mocha_phantomjs']);
grunt.registerTask('default', ['jshint', 'mochaTest', 'connect:test', 'mocha_phantomjs']);
};
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mailbuild",
"version": "0.1.0",
"version": "0.2.0",
"homepage": "https://github.com/whiteout-io/mailbuild",
"description": "mailbuild is a low level rfc2822 message composer. Define your own mime tree, no magic included.",
"author": "Andris Reinman <[email protected]>",
Expand All @@ -18,7 +18,7 @@
},
"main": "src/mailbuild",
"dependencies": {
"mimefuncs": "https://github.com/whiteout-io/mimefuncs/tarball/v0.1.5",
"mimefuncs": "https://github.com/whiteout-io/mimefuncs/tarball/v0.2.0",
"mimetypes": " https://github.com/whiteout-io/mimetypes/tarball/v0.1.1",
"addressparser": "https://github.com/whiteout-io/addressparser/tarball/v0.1.2",
"punycode": "~1.2.4"
Expand All @@ -29,12 +29,12 @@
"grunt-mocha-phantomjs": "~0.4.0",
"grunt-contrib-connect": "~0.6.0",
"grunt-contrib-jshint": "~0.8.0",
"grunt-mocha-test": "~0.8.1",
"grunt-mocha-test": "~0.10.0",
"mocha": "~1.16.2",
"phantomjs": "~1.9.7-1",
"requirejs": "~2.1.10",
"arraybuffer-slice": "~0.0.2",
"stringencoding": "https://github.com/whiteout-io/stringencoding/tarball/v0.1.0"
"amdefine": "^0.1.0"
},
"volo": {}
}
2 changes: 2 additions & 0 deletions src/mailbuild.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@

if (typeof define === 'function' && define.amd) {
define(['mimefuncs', 'mimetypes', 'punycode', 'addressparser'], factory);
} else if (typeof exports === 'object') {
module.exports = factory(require('mimefuncs'), require('mimetypes'), require('punycode'), require('addressparser'));
} else {
root.mailbuild = factory(mimefuncs, mimetypes, punycode, addressparser);
}
Expand Down
4 changes: 0 additions & 4 deletions test/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@
<!-- phantomjs polyfill for ArrayBuffer.slice -->
<script src="../node_modules/arraybuffer-slice/index.js"></script>

<!-- polyfill for TextEncoder/TextDecoder -->
<script src="../node_modules/stringencoding/encoding-indexes.js"></script>
<script src="../node_modules/stringencoding/encoding.js"></script>

<script src="../node_modules/mocha/mocha.js"></script>
<script data-main="index.js" src="../node_modules/requirejs/require.js"></script>
</body>
Expand Down
5 changes: 3 additions & 2 deletions test/index.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
'use strict';

require.config({
baseUrl: '../src',
baseUrl: '../',
paths: {
'test': '../test',
'chai': '../node_modules/chai/chai',
'addressparser': '../node_modules/addressparser/src/addressparser',
'mimetypes': '../node_modules/mimetypes/src/mimetypes',
'mimefuncs': '../node_modules/mimefuncs/src/mimefuncs',
'punycode': '../node_modules/punycode/punycode.min'
'punycode': '../node_modules/punycode/punycode.min',
'stringencoding': '../node_modules/mimefuncs/node_modules/stringencoding/dist/stringencoding'
}
});

Expand Down
9 changes: 7 additions & 2 deletions test/mailbuild-unit.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
define(['chai', 'mailbuild'], function(chai, mailbuild) {
'use strict';
'use strict';

if (typeof define !== 'function') {
var define = require('amdefine')(module);
}

define(['chai', '../src/mailbuild'], function(chai, mailbuild) {

var expect = chai.expect;
chai.Assertion.includeStack = true;
Expand Down

0 comments on commit 79f8f81

Please sign in to comment.