Skip to content

Commit

Permalink
Merge pull request #97 from box/issue76
Browse files Browse the repository at this point in the history
Breaking: Use NativeDOM by default (fixes #76)
  • Loading branch information
nzakas committed Aug 13, 2015
2 parents 6412852 + 4c7a1c4 commit 0a193e0
Show file tree
Hide file tree
Showing 4 changed files with 91 additions and 4 deletions.
18 changes: 15 additions & 3 deletions Makefile.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ var NODE = 'node ', // intentional extra space

// Utilities - intentional extra space at the end of each string
ISTANBUL = NODE + NODE_MODULES + 'istanbul/lib/cli.js ',
MOCHA = NODE_MODULES + 'mocha/bin/_mocha ',
JSDOC = NODE + NODE_MODULES + 'jsdoc/jsdoc.js ',

// Since our npm package name is actually 't3js'
Expand Down Expand Up @@ -232,6 +231,19 @@ target.test = function() {
if (code !== 0) {
exit(code);
}

echo('Running API tests');
target['api-test']();
};

target['api-test'] = function() {
// generate dist files that are used by api-test
target.dist();

nodeExec('mocha', './tests/api-test.js');

// revert generated files
execOrExit('git checkout dist');
};

target['test-watch'] = function() {
Expand Down Expand Up @@ -301,8 +313,8 @@ target.dist = function() {
testingFiles: TESTING_JQUERY_FILES
}, {
name: DIST_NAME,
files: SRC_JQUERY_FILES,
testingFiles: TESTING_JQUERY_FILES
files: SRC_NATIVE_FILES,
testingFiles: TESTING_NATIVE_FILES
}].forEach(function(dist){
generateDistFiles(dist);
});
Expand Down
1 change: 1 addition & 0 deletions config/karma-conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ module.exports = function(config) {

// list of files to exclude
exclude: [
'tests/api-test.js'
],

// preprocess matching files before serving them to the browser
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"minor": "node Makefile.js minor",
"major": "node Makefile.js major"
},
"main": "dist/t3.js",
"main": "dist/t3-native.js",
"devDependencies": {
"assertive-chai": "^1.0.2",
"dateformat": "^1.0.11",
Expand Down
74 changes: 74 additions & 0 deletions tests/api-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/**
* @fileoverview Tests for T3 API (package.json and dist files)
* @author Box
*/

'use strict';

// @NOTE(nzakas): This file runs in Node.js, not Karma!

//------------------------------------------------------------------------------
// Requirements
//------------------------------------------------------------------------------

var assert = require('assertive-chai').assert,
leche = require('leche'),
path = require('path'),
defaultT3 = require('../dist/t3'),
nativeT3 = require('../dist/t3-native'),
jqueryT3 = require('../dist/t3-jquery'),
pkg = require('../package.json');

//------------------------------------------------------------------------------
// Tests
//------------------------------------------------------------------------------

describe('API', function() {

describe('Defaults', function() {
it('should use native DOM in default file', function() {
assert.equal(defaultT3.DOM.type, 'native');
});

it('should use native DOM in native file', function() {
assert.equal(nativeT3.DOM.type, 'native');
});

it('should use jQuery DOM in jQuery file', function() {
assert.equal(jqueryT3.DOM.type, 'jquery');
});
});

describe('Exports', function() {

leche.withData({
'Default T3': defaultT3,
'Native T3': nativeT3,
'jQuery T3': jqueryT3
}, function(T3) {

leche.withData([
'DOM',
'DOMEventDelegate',
'EventTarget',
'Application',
'Context'
], function(name) {
it('should have Box.' + name, function() {
assert.isDefined(T3[name]);
});
});

});

});

describe('package.json', function() {

it('should export native T3', function() {
assert.equal(require(path.join('../', pkg.main)), nativeT3);
});

});

});

0 comments on commit 0a193e0

Please sign in to comment.