From 9acbf8d7ee3dda4fcd41ea11035b2b25885485ca Mon Sep 17 00:00:00 2001 From: Lee Bousfield Date: Mon, 9 May 2016 20:47:06 -0600 Subject: [PATCH] Added testem support Resolves #1 --- .travis.yml | 2 + gulpfile.js | 37 + package.json | 15 +- testem.json | 6 + testem/build/tests.js | 48832 ++++++++++++++++++++++++++++++++++++++++ testem/src/index.js | 35 + 6 files changed, 48925 insertions(+), 2 deletions(-) create mode 100644 gulpfile.js create mode 100644 testem.json create mode 100644 testem/build/tests.js create mode 100644 testem/src/index.js diff --git a/.travis.yml b/.travis.yml index 3ed46a2..4a44394 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,5 +4,7 @@ node_js: - 'iojs-v2.5.0' install: - npm install +script: + - npm run testem-ci notifications: email: false diff --git a/gulpfile.js b/gulpfile.js new file mode 100644 index 0000000..21089f0 --- /dev/null +++ b/gulpfile.js @@ -0,0 +1,37 @@ +var gulp = require('gulp'); +var webpack = require('webpack-stream'); + +gulp.task('testem-js', function() { + return gulp.src('testem/src/index.js') + .pipe(webpack({ + module: { + loaders: [ + { + test: /\.jsx?$/, + exclude: /node_modules/, + loader: 'babel', + query: { + presets: ['es2015', 'stage-0'], + plugins: ['transform-react-jsx', 'transform-runtime'] + } + } + ] + }, + node: { + fs: 'empty' + }, + output: { + filename: 'tests.js' + } + })) + .pipe(gulp.dest('testem/build')); +}); + +gulp.task('build-testem', ['testem-js']); + +gulp.task('watch-testem', ['build-testem'], function () { + gulp.watch('src/*.js', ['testem-js']); + gulp.watch('testem/src/*.js', ['testem-js']); +}); + +gulp.task('default', ['build-testem']); diff --git a/package.json b/package.json index 0a712a2..299ea40 100644 --- a/package.json +++ b/package.json @@ -31,12 +31,21 @@ }, "devDependencies": { "@kadira/storybook": "^1.2.0", + "babel-core": "^6.8.0", + "babel-loader": "^6.2.4", + "babel-plugin-transform-react-jsx": "^6.8.0", + "babel-plugin-transform-runtime": "^6.8.0", + "babel-preset-es2015": "^6.6.0", + "babel-preset-stage-0": "^6.5.0", "chai": "^3.5.0", + "gulp": "^3.9.1", "jsdom": "^8.3.0", "pragmatist": "^3.0.21", + "qunit": "^0.9.1", "react": "^0.14.8", "react-addons-test-utils": "^0.14.8", - "react-dom": "^0.14.8" + "react-dom": "^0.14.8", + "webpack-stream": "^3.2.0" }, "scripts": { "pragmatist": "pragmatist", @@ -45,6 +54,8 @@ "build": "pragmatist --es5 build", "watch-build": "pragmatist --es5 watch-build", "preversion": "npm run lint && npm run test && npm run build", - "demo": "start-storybook -p 9001" + "demo": "start-storybook -p 9001", + "testem": "testem", + "testem-ci": "testem ci -l PhantomJS" } } diff --git a/testem.json b/testem.json new file mode 100644 index 0000000..702b36c --- /dev/null +++ b/testem.json @@ -0,0 +1,6 @@ +{ + "framework": "mocha", + "src_files": [ + "testem/build/*.js" + ] +} diff --git a/testem/build/tests.js b/testem/build/tests.js new file mode 100644 index 0000000..3a62d06 --- /dev/null +++ b/testem/build/tests.js @@ -0,0 +1,48832 @@ +/******/ (function(modules) { // webpackBootstrap +/******/ // The module cache +/******/ var installedModules = {}; + +/******/ // The require function +/******/ function __webpack_require__(moduleId) { + +/******/ // Check if module is in cache +/******/ if(installedModules[moduleId]) +/******/ return installedModules[moduleId].exports; + +/******/ // Create a new module (and put it into the cache) +/******/ var module = installedModules[moduleId] = { +/******/ exports: {}, +/******/ id: moduleId, +/******/ loaded: false +/******/ }; + +/******/ // Execute the module function +/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); + +/******/ // Flag the module as loaded +/******/ module.loaded = true; + +/******/ // Return the exports of the module +/******/ return module.exports; +/******/ } + + +/******/ // expose the modules object (__webpack_modules__) +/******/ __webpack_require__.m = modules; + +/******/ // expose the module cache +/******/ __webpack_require__.c = installedModules; + +/******/ // __webpack_public_path__ +/******/ __webpack_require__.p = ""; + +/******/ // Load entry module and return exports +/******/ return __webpack_require__(0); +/******/ }) +/************************************************************************/ +/******/ ([ +/* 0 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var _from = __webpack_require__(1); + + var _from2 = _interopRequireDefault(_from); + + var _react = __webpack_require__(54); + + var _react2 = _interopRequireDefault(_react); + + var _reactDom = __webpack_require__(211); + + var _reactDom2 = _interopRequireDefault(_reactDom); + + var _index = __webpack_require__(212); + + var _index2 = _interopRequireDefault(_index); + + var _assert = __webpack_require__(382); + + var _assert2 = _interopRequireDefault(_assert); + + function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + + var dom = document.createElement('div'); + dom.id = 'dom'; + + describe('ReactYoutubePlayer', function () { + before(function () { + document.body.appendChild(dom); + }); + + it('should render a Youtube player', function (done) { + _reactDom2.default.render(_react2.default.createElement(_index2.default, { + videoId: 'M7lc1UVf-VE', + width: '640', + height: '360', + playbackState: 'unstarted' + }), dom, done); + }); + + it('should properly create the player', function (done) { + this.slow(2000); + setTimeout(function () { + var iframes = (0, _from2.default)(document.getElementsByTagName('iframe')); + iframes = iframes.filter(function (iframe) { + return iframe.src.indexOf('youtube') !== -1; + }); + _assert2.default.equal(iframes.length, 1); + done(); + }, 500); + }); + }); + +/***/ }, +/* 1 */ +/***/ function(module, exports, __webpack_require__) { + + module.exports = { "default": __webpack_require__(2), __esModule: true }; + +/***/ }, +/* 2 */ +/***/ function(module, exports, __webpack_require__) { + + __webpack_require__(3); + __webpack_require__(47); + module.exports = __webpack_require__(11).Array.from; + +/***/ }, +/* 3 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + var $at = __webpack_require__(4)(true); + + // 21.1.3.27 String.prototype[@@iterator]() + __webpack_require__(7)(String, 'String', function(iterated){ + this._t = String(iterated); // target + this._i = 0; // next index + // 21.1.5.2.1 %StringIteratorPrototype%.next() + }, function(){ + var O = this._t + , index = this._i + , point; + if(index >= O.length)return {value: undefined, done: true}; + point = $at(O, index); + this._i += point.length; + return {value: point, done: false}; + }); + +/***/ }, +/* 4 */ +/***/ function(module, exports, __webpack_require__) { + + var toInteger = __webpack_require__(5) + , defined = __webpack_require__(6); + // true -> String#at + // false -> String#codePointAt + module.exports = function(TO_STRING){ + return function(that, pos){ + var s = String(defined(that)) + , i = toInteger(pos) + , l = s.length + , a, b; + if(i < 0 || i >= l)return TO_STRING ? '' : undefined; + a = s.charCodeAt(i); + return a < 0xd800 || a > 0xdbff || i + 1 === l || (b = s.charCodeAt(i + 1)) < 0xdc00 || b > 0xdfff + ? TO_STRING ? s.charAt(i) : a + : TO_STRING ? s.slice(i, i + 2) : (a - 0xd800 << 10) + (b - 0xdc00) + 0x10000; + }; + }; + +/***/ }, +/* 5 */ +/***/ function(module, exports) { + + // 7.1.4 ToInteger + var ceil = Math.ceil + , floor = Math.floor; + module.exports = function(it){ + return isNaN(it = +it) ? 0 : (it > 0 ? floor : ceil)(it); + }; + +/***/ }, +/* 6 */ +/***/ function(module, exports) { + + // 7.2.1 RequireObjectCoercible(argument) + module.exports = function(it){ + if(it == undefined)throw TypeError("Can't call method on " + it); + return it; + }; + +/***/ }, +/* 7 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + var LIBRARY = __webpack_require__(8) + , $export = __webpack_require__(9) + , redefine = __webpack_require__(24) + , hide = __webpack_require__(14) + , has = __webpack_require__(25) + , Iterators = __webpack_require__(26) + , $iterCreate = __webpack_require__(27) + , setToStringTag = __webpack_require__(43) + , getPrototypeOf = __webpack_require__(45) + , ITERATOR = __webpack_require__(44)('iterator') + , BUGGY = !([].keys && 'next' in [].keys()) // Safari has buggy iterators w/o `next` + , FF_ITERATOR = '@@iterator' + , KEYS = 'keys' + , VALUES = 'values'; + + var returnThis = function(){ return this; }; + + module.exports = function(Base, NAME, Constructor, next, DEFAULT, IS_SET, FORCED){ + $iterCreate(Constructor, NAME, next); + var getMethod = function(kind){ + if(!BUGGY && kind in proto)return proto[kind]; + switch(kind){ + case KEYS: return function keys(){ return new Constructor(this, kind); }; + case VALUES: return function values(){ return new Constructor(this, kind); }; + } return function entries(){ return new Constructor(this, kind); }; + }; + var TAG = NAME + ' Iterator' + , DEF_VALUES = DEFAULT == VALUES + , VALUES_BUG = false + , proto = Base.prototype + , $native = proto[ITERATOR] || proto[FF_ITERATOR] || DEFAULT && proto[DEFAULT] + , $default = $native || getMethod(DEFAULT) + , $entries = DEFAULT ? !DEF_VALUES ? $default : getMethod('entries') : undefined + , $anyNative = NAME == 'Array' ? proto.entries || $native : $native + , methods, key, IteratorPrototype; + // Fix native + if($anyNative){ + IteratorPrototype = getPrototypeOf($anyNative.call(new Base)); + if(IteratorPrototype !== Object.prototype){ + // Set @@toStringTag to native iterators + setToStringTag(IteratorPrototype, TAG, true); + // fix for some old engines + if(!LIBRARY && !has(IteratorPrototype, ITERATOR))hide(IteratorPrototype, ITERATOR, returnThis); + } + } + // fix Array#{values, @@iterator}.name in V8 / FF + if(DEF_VALUES && $native && $native.name !== VALUES){ + VALUES_BUG = true; + $default = function values(){ return $native.call(this); }; + } + // Define iterator + if((!LIBRARY || FORCED) && (BUGGY || VALUES_BUG || !proto[ITERATOR])){ + hide(proto, ITERATOR, $default); + } + // Plug for library + Iterators[NAME] = $default; + Iterators[TAG] = returnThis; + if(DEFAULT){ + methods = { + values: DEF_VALUES ? $default : getMethod(VALUES), + keys: IS_SET ? $default : getMethod(KEYS), + entries: $entries + }; + if(FORCED)for(key in methods){ + if(!(key in proto))redefine(proto, key, methods[key]); + } else $export($export.P + $export.F * (BUGGY || VALUES_BUG), NAME, methods); + } + return methods; + }; + +/***/ }, +/* 8 */ +/***/ function(module, exports) { + + module.exports = true; + +/***/ }, +/* 9 */ +/***/ function(module, exports, __webpack_require__) { + + var global = __webpack_require__(10) + , core = __webpack_require__(11) + , ctx = __webpack_require__(12) + , hide = __webpack_require__(14) + , PROTOTYPE = 'prototype'; + + var $export = function(type, name, source){ + var IS_FORCED = type & $export.F + , IS_GLOBAL = type & $export.G + , IS_STATIC = type & $export.S + , IS_PROTO = type & $export.P + , IS_BIND = type & $export.B + , IS_WRAP = type & $export.W + , exports = IS_GLOBAL ? core : core[name] || (core[name] = {}) + , expProto = exports[PROTOTYPE] + , target = IS_GLOBAL ? global : IS_STATIC ? global[name] : (global[name] || {})[PROTOTYPE] + , key, own, out; + if(IS_GLOBAL)source = name; + for(key in source){ + // contains in native + own = !IS_FORCED && target && target[key] !== undefined; + if(own && key in exports)continue; + // export native or passed + out = own ? target[key] : source[key]; + // prevent global pollution for namespaces + exports[key] = IS_GLOBAL && typeof target[key] != 'function' ? source[key] + // bind timers to global for call from export context + : IS_BIND && own ? ctx(out, global) + // wrap global constructors for prevent change them in library + : IS_WRAP && target[key] == out ? (function(C){ + var F = function(a, b, c){ + if(this instanceof C){ + switch(arguments.length){ + case 0: return new C; + case 1: return new C(a); + case 2: return new C(a, b); + } return new C(a, b, c); + } return C.apply(this, arguments); + }; + F[PROTOTYPE] = C[PROTOTYPE]; + return F; + // make static versions for prototype methods + })(out) : IS_PROTO && typeof out == 'function' ? ctx(Function.call, out) : out; + // export proto methods to core.%CONSTRUCTOR%.methods.%NAME% + if(IS_PROTO){ + (exports.virtual || (exports.virtual = {}))[key] = out; + // export proto methods to core.%CONSTRUCTOR%.prototype.%NAME% + if(type & $export.R && expProto && !expProto[key])hide(expProto, key, out); + } + } + }; + // type bitmap + $export.F = 1; // forced + $export.G = 2; // global + $export.S = 4; // static + $export.P = 8; // proto + $export.B = 16; // bind + $export.W = 32; // wrap + $export.U = 64; // safe + $export.R = 128; // real proto method for `library` + module.exports = $export; + +/***/ }, +/* 10 */ +/***/ function(module, exports) { + + // https://github.com/zloirock/core-js/issues/86#issuecomment-115759028 + var global = module.exports = typeof window != 'undefined' && window.Math == Math + ? window : typeof self != 'undefined' && self.Math == Math ? self : Function('return this')(); + if(typeof __g == 'number')__g = global; // eslint-disable-line no-undef + +/***/ }, +/* 11 */ +/***/ function(module, exports) { + + var core = module.exports = {version: '2.4.0'}; + if(typeof __e == 'number')__e = core; // eslint-disable-line no-undef + +/***/ }, +/* 12 */ +/***/ function(module, exports, __webpack_require__) { + + // optional / simple context binding + var aFunction = __webpack_require__(13); + module.exports = function(fn, that, length){ + aFunction(fn); + if(that === undefined)return fn; + switch(length){ + case 1: return function(a){ + return fn.call(that, a); + }; + case 2: return function(a, b){ + return fn.call(that, a, b); + }; + case 3: return function(a, b, c){ + return fn.call(that, a, b, c); + }; + } + return function(/* ...args */){ + return fn.apply(that, arguments); + }; + }; + +/***/ }, +/* 13 */ +/***/ function(module, exports) { + + module.exports = function(it){ + if(typeof it != 'function')throw TypeError(it + ' is not a function!'); + return it; + }; + +/***/ }, +/* 14 */ +/***/ function(module, exports, __webpack_require__) { + + var dP = __webpack_require__(15) + , createDesc = __webpack_require__(23); + module.exports = __webpack_require__(19) ? function(object, key, value){ + return dP.f(object, key, createDesc(1, value)); + } : function(object, key, value){ + object[key] = value; + return object; + }; + +/***/ }, +/* 15 */ +/***/ function(module, exports, __webpack_require__) { + + var anObject = __webpack_require__(16) + , IE8_DOM_DEFINE = __webpack_require__(18) + , toPrimitive = __webpack_require__(22) + , dP = Object.defineProperty; + + exports.f = __webpack_require__(19) ? Object.defineProperty : function defineProperty(O, P, Attributes){ + anObject(O); + P = toPrimitive(P, true); + anObject(Attributes); + if(IE8_DOM_DEFINE)try { + return dP(O, P, Attributes); + } catch(e){ /* empty */ } + if('get' in Attributes || 'set' in Attributes)throw TypeError('Accessors not supported!'); + if('value' in Attributes)O[P] = Attributes.value; + return O; + }; + +/***/ }, +/* 16 */ +/***/ function(module, exports, __webpack_require__) { + + var isObject = __webpack_require__(17); + module.exports = function(it){ + if(!isObject(it))throw TypeError(it + ' is not an object!'); + return it; + }; + +/***/ }, +/* 17 */ +/***/ function(module, exports) { + + module.exports = function(it){ + return typeof it === 'object' ? it !== null : typeof it === 'function'; + }; + +/***/ }, +/* 18 */ +/***/ function(module, exports, __webpack_require__) { + + module.exports = !__webpack_require__(19) && !__webpack_require__(20)(function(){ + return Object.defineProperty(__webpack_require__(21)('div'), 'a', {get: function(){ return 7; }}).a != 7; + }); + +/***/ }, +/* 19 */ +/***/ function(module, exports, __webpack_require__) { + + // Thank's IE8 for his funny defineProperty + module.exports = !__webpack_require__(20)(function(){ + return Object.defineProperty({}, 'a', {get: function(){ return 7; }}).a != 7; + }); + +/***/ }, +/* 20 */ +/***/ function(module, exports) { + + module.exports = function(exec){ + try { + return !!exec(); + } catch(e){ + return true; + } + }; + +/***/ }, +/* 21 */ +/***/ function(module, exports, __webpack_require__) { + + var isObject = __webpack_require__(17) + , document = __webpack_require__(10).document + // in old IE typeof document.createElement is 'object' + , is = isObject(document) && isObject(document.createElement); + module.exports = function(it){ + return is ? document.createElement(it) : {}; + }; + +/***/ }, +/* 22 */ +/***/ function(module, exports, __webpack_require__) { + + // 7.1.1 ToPrimitive(input [, PreferredType]) + var isObject = __webpack_require__(17); + // instead of the ES6 spec version, we didn't implement @@toPrimitive case + // and the second argument - flag - preferred type is a string + module.exports = function(it, S){ + if(!isObject(it))return it; + var fn, val; + if(S && typeof (fn = it.toString) == 'function' && !isObject(val = fn.call(it)))return val; + if(typeof (fn = it.valueOf) == 'function' && !isObject(val = fn.call(it)))return val; + if(!S && typeof (fn = it.toString) == 'function' && !isObject(val = fn.call(it)))return val; + throw TypeError("Can't convert object to primitive value"); + }; + +/***/ }, +/* 23 */ +/***/ function(module, exports) { + + module.exports = function(bitmap, value){ + return { + enumerable : !(bitmap & 1), + configurable: !(bitmap & 2), + writable : !(bitmap & 4), + value : value + }; + }; + +/***/ }, +/* 24 */ +/***/ function(module, exports, __webpack_require__) { + + module.exports = __webpack_require__(14); + +/***/ }, +/* 25 */ +/***/ function(module, exports) { + + var hasOwnProperty = {}.hasOwnProperty; + module.exports = function(it, key){ + return hasOwnProperty.call(it, key); + }; + +/***/ }, +/* 26 */ +/***/ function(module, exports) { + + module.exports = {}; + +/***/ }, +/* 27 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + var create = __webpack_require__(28) + , descriptor = __webpack_require__(23) + , setToStringTag = __webpack_require__(43) + , IteratorPrototype = {}; + + // 25.1.2.1.1 %IteratorPrototype%[@@iterator]() + __webpack_require__(14)(IteratorPrototype, __webpack_require__(44)('iterator'), function(){ return this; }); + + module.exports = function(Constructor, NAME, next){ + Constructor.prototype = create(IteratorPrototype, {next: descriptor(1, next)}); + setToStringTag(Constructor, NAME + ' Iterator'); + }; + +/***/ }, +/* 28 */ +/***/ function(module, exports, __webpack_require__) { + + // 19.1.2.2 / 15.2.3.5 Object.create(O [, Properties]) + var anObject = __webpack_require__(16) + , dPs = __webpack_require__(29) + , enumBugKeys = __webpack_require__(41) + , IE_PROTO = __webpack_require__(38)('IE_PROTO') + , Empty = function(){ /* empty */ } + , PROTOTYPE = 'prototype'; + + // Create object with fake `null` prototype: use iframe Object with cleared prototype + var createDict = function(){ + // Thrash, waste and sodomy: IE GC bug + var iframe = __webpack_require__(21)('iframe') + , i = enumBugKeys.length + , gt = '>' + , iframeDocument; + iframe.style.display = 'none'; + __webpack_require__(42).appendChild(iframe); + iframe.src = 'javascript:'; // eslint-disable-line no-script-url + // createDict = iframe.contentWindow.Object; + // html.removeChild(iframe); + iframeDocument = iframe.contentWindow.document; + iframeDocument.open(); + iframeDocument.write('