From: Iskren Chernev Date: Mon, 23 Mar 2015 00:20:38 +0000 (-0700) Subject: Fix tests in karma/sauce X-Git-Tag: 2.10.2~15^2~15 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d281de7a2d7b0017bf88b1c49347d3edcc87852a;p=thirdparty%2Fmoment.git Fix tests in karma/sauce --- diff --git a/Gruntfile.js b/Gruntfile.js index 6a4f17acf..9e8ffdee5 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -1,45 +1,16 @@ module.exports = function (grunt) { - var embedOption = grunt.option('embedLocales'), - embedLocaleDest = embedOption ? - 'min/moment-with-customlocales.js' : - 'min/moment-with-locales.js', - embedLocaleSrc = 'locale/*.js'; - - if (embedOption && embedOption.match(/,/)) { - embedLocaleSrc = 'locale/{' + embedOption + '}.js'; - } - else if (embedOption) { - embedLocaleSrc = 'locale/' + embedOption + '.js'; - } - grunt.initConfig({ pkg: grunt.file.readJSON('package.json'), - concat : { - locales: { - src: 'locale/*.js', - dest: 'min/locales.js' - }, - tests: { - src: [ - 'test/browser-prefix.js', - 'test/moment/*.js', - 'test/locale/*.js', - 'test/browser-suffix.js' - ], - dest: 'min/tests.js' - } - }, env : { sauceLabs : (grunt.file.exists('.sauce-labs.creds') ? grunt.file.readJSON('.sauce-labs.creds') : {}) }, karma : { options: { - frameworks: ['nodeunit'], + frameworks: ['qunit'], files: [ - 'min/moment-with-locales.js', - 'min/tests.js', - 'test/browser.js' + 'build/umd/min/moment-with-locales.js', + 'build/umd/min/tests.js' ], sauceLabs: { startConnect: true, @@ -98,7 +69,6 @@ module.exports = function (grunt) { ] } }, - uglify : { main: { files: { @@ -107,11 +77,6 @@ module.exports = function (grunt) { 'min/moment.min.js' : 'moment.js' } }, - customlocales: { - files: { - 'min/moment-with-customlocales.min.js' : 'min/moment-with-customlocales.js' - } - }, options: { mangle: true, compress: { @@ -124,9 +89,6 @@ module.exports = function (grunt) { preserveComments: 'some' } }, - nodeunit : { - all : ['test/moment/**/*.js', 'test/locale/**/*.js'] - }, jshint: { all: [ 'Gruntfile.js', @@ -150,22 +112,15 @@ module.exports = function (grunt) { watch : { test : { files : [ - 'moment.js', - 'locale/*.js', - 'test/**/*.js' + 'src/**/*.js', ], - tasks: ['nodeunit'] + tasks: ['test'] }, jshint : { files : '<%= jshint.all %>', tasks: ['jshint'] } }, - embedLocales: { - moment: 'moment.js', - dest: embedLocaleDest, - targetLocales: embedLocaleSrc - }, benchmark: { all: { src: ['benchmarks/*.js'] @@ -210,10 +165,10 @@ module.exports = function (grunt) { // test tasks grunt.registerTask('test', ['test:node']); grunt.registerTask('test:node', ['transpile', 'qtest']); - grunt.registerTask('test:server', ['concat', 'embedLocales', 'karma:server']); - grunt.registerTask('test:browser', ['concat', 'embedLocales', 'karma:chrome', 'karma:firefox']); - grunt.registerTask('test:sauce-browser', ['concat', 'embedLocales', 'env:sauceLabs', 'karma:sauce']); - grunt.registerTask('test:travis-sauce-browser', ['concat', 'embedLocales', 'karma:sauce']); + grunt.registerTask('test:server', ['transpile', 'karma:server']); + grunt.registerTask('test:browser', ['transpile', 'karma:chrome', 'karma:firefox']); + grunt.registerTask('test:sauce-browser', ['transpile', 'env:sauceLabs', 'karma:sauce']); + grunt.registerTask('test:travis-sauce-browser', ['transpile', 'karma:sauce']); grunt.registerTask('test:meteor', ['exec:meteor-init', 'exec:meteor-test', 'exec:meteor-cleanup']); // travis build task @@ -222,7 +177,9 @@ module.exports = function (grunt) { // Task to be run when releasing a new version grunt.registerTask('release', [ - 'jshint', 'nodeunit', 'concat', 'embedLocales', - 'component', 'uglify:main' + 'default', + 'update-index', + 'component', + 'uglify:main' ]); }; diff --git a/package.json b/package.json index cf5c1a6a4..598e0c048 100644 --- a/package.json +++ b/package.json @@ -49,13 +49,11 @@ "broccoli-uglify-js": "^0.1.3", "es6-promise": "latest", "grunt": "latest", - "nodeunit": "latest", "benchmark": "latest", "grunt-contrib-clean": "latest", + "grunt-contrib-concat": "latest", "grunt-contrib-copy": "latest", "grunt-contrib-jshint": "latest", - "grunt-contrib-nodeunit": "latest", - "grunt-contrib-concat": "latest", "grunt-contrib-uglify": "latest", "grunt-contrib-watch": "latest", "grunt-env": "latest", @@ -69,7 +67,7 @@ "karma": "latest", "karma-chrome-launcher": "latest", "karma-firefox-launcher": "latest", - "karma-nodeunit": "latest", + "karma-qunit": "latest", "karma-sauce-launcher": "latest", "qunit": "^0.7.5", "qunit-cli": "^0.1.4", diff --git a/src/test/locale/zh-cn.js b/src/test/locale/zh-cn.js index 67323d79f..5097083ba 100644 --- a/src/test/locale/zh-cn.js +++ b/src/test/locale/zh-cn.js @@ -156,6 +156,7 @@ test('calendar next week', function (assert) { } assert.equal(m.calendar(), m.format('[下]ddd凌晨12点整'), 'Today + ' + i + ' days beginning of day'); } + assert.equal(42, 42, "at least one assert"); }); test('calendar last week', function (assert) { @@ -169,8 +170,7 @@ test('calendar last week', function (assert) { } assert.equal(m.calendar(), m.format('[上]ddd凌晨12点整'), 'Monday - ' + i + ' days next week'); } - // ensure at least one assertion is run - assert.equal(42, 42); + assert.equal(42, 42, "at least one assert"); }); test('calendar all else', function (assert) { diff --git a/src/test/moment/diff.js b/src/test/moment/diff.js index 49f1c613a..d1821fa7a 100644 --- a/src/test/moment/diff.js +++ b/src/test/moment/diff.js @@ -105,6 +105,7 @@ test('diff month', function (assert) { test('diff across DST', function (assert) { var dst = dstForYear(2012), a, b, daysInMonth; if (!dst) { + assert.equal(42, 42, "at least one assertion"); return; } diff --git a/tasks/transpile.js b/tasks/transpile.js index 8dcb1524e..9f70f83ad 100644 --- a/tasks/transpile.js +++ b/tasks/transpile.js @@ -4,6 +4,11 @@ module.exports = function (grunt) { var Promise = require('es6-promise').Promise; var TMP_DIR = 'build/tmp'; + grunt.config('concat.tests', { + src: 'build/umd/test/**/*.js', + dest: 'build/umd/min/tests.js' + }); + function moveComments(code) { var comments = [], rest = []; code.split('\n').forEach(function (line) { @@ -104,7 +109,7 @@ module.exports = function (grunt) { }); } - grunt.task.registerTask('transpile', 'convert es6 to umd', function () { + grunt.task.registerTask('transpile-raw', 'convert es6 to umd', function () { var done = this.async(); grunt.log.writeln('cleaning up build'); @@ -178,7 +183,7 @@ module.exports = function (grunt) { target: 'build/umd/min/moment-with-locales.js' }).then(function () { var code = grunt.file.read('build/umd/min/moment-with-locales.js'); - code = code.replace(' var moment = {\n get default () { return moment__default; }\n };', ''); + code = code.replace(' var moment = {\n get default () { return moment__default; }\n };', ''); code = code.replace('var moment_with_locales = moment', 'var moment_with_locales = moment__default'); grunt.file.write('build/umd/min/moment-with-locales.js', code); }); @@ -187,4 +192,6 @@ module.exports = function (grunt) { done(e); }); }); + + grunt.registerTask('transpile', ['transpile-raw', 'concat:tests']); }; diff --git a/templates/test-header.js b/templates/test-header.js index 80ec8ef8a..38940c3ec 100644 --- a/templates/test-header.js +++ b/templates/test-header.js @@ -1,4 +1,5 @@ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../../moment')) : - typeof define === 'function' && define.amd && define(['../../moment'], factory); + typeof define === 'function' && define.amd ? define(['../../moment'], factory) : + factory(global.moment) }(this, function (moment) { 'use strict';