11'use strict' ;
2+ var fs = require ( 'fs' ) ;
3+
4+ var glob = require ( 'glob' ) ;
5+ var busterAmd = require ( 'buster-amd' ) ;
6+
7+ var conditionalLoadGenerator = require ( './node-es6/conditional-load-generator' ) ;
28
39require ( 'gent/test-adapter/buster' ) ;
410
11+ var tests = [ 'node/**/*.js' ] ;
12+ var nodeTests = tests . slice ( ) ;
13+ var es6Tests = glob . sync ( 'node-es6/**/*-test.js' ) ;
14+ var conditionalBrowserLoaders = [ 'node-es6/var/conditional-load.js' ] ;
15+
16+ // begin node test setup
17+
518function evaluates ( statement ) {
619 try {
720 /* jshint evil: true */
@@ -21,22 +34,48 @@ function isSpreadAvailable() {
2134 return evaluates ( 'parseInt(...["20", 10])' ) ;
2235}
2336
24- var tests = [ 'node/**/*-test.js' ] ;
25-
26- console . log ( 'class operator %savailable' , isClassAvailable ( ) ? '' : 'not ' ) ;
27- console . log ( 'spread operator %savailable' , isSpreadAvailable ( ) ? '' : 'not ' ) ;
28-
37+ console . log ( 'class operator %savailable in node' , isClassAvailable ( ) ? '' : 'not ' ) ;
38+ console . log ( 'spread operator %savailable in node' , isSpreadAvailable ( ) ? '' : 'not ' ) ;
2939if (
3040 isClassAvailable ( )
3141 && isSpreadAvailable ( )
3242 && ! ( 'ES_VERSION' in process . env && parseFloat ( process . env . ES_VERSION ) < 6 )
3343) {
34- tests . push ( 'node-es6/**/*-test.js' ) ;
44+ nodeTests = nodeTests . concat ( es6Tests ) ;
3545}
3646
3747module . exports [ 'node' ] = {
3848 environment : 'node' ,
39- tests : tests
49+ tests : tests . concat ( nodeTests )
4050 // TODO: Why doesn't this work?
4151 //, testHelpers:['gent/test-adapter/buster']
4252} ;
53+
54+ // begin browser test setup
55+
56+ // hack, we have to detect if browser is es6 capable in browser itself
57+ // and load es6 tests only when that is true
58+ // but to load es6 tests in browser we have to have list of them after decision
59+ // whether to load them is made. I found no other way to pass this list to browser
60+ // than with static file
61+ fs . writeFileSync (
62+ __dirname + '/node-es6/var/conditional-load.js' ,
63+ conditionalLoadGenerator ( es6Tests . map ( function ( e ) { return 'test/' + e ; } ) )
64+ ) ;
65+
66+
67+ module . exports [ 'browser' ] = {
68+ environment : 'browser' ,
69+ rootPath : '../' ,
70+ libs : [
71+ 'node_modules/requirejs/require.js' ,
72+ 'test/requirejs-main.js' ,
73+ ] ,
74+ sources :
75+ [ 'lib/**/*.js' , 'lib/*.js' , 'node_modules/{gent,meld,when}/**/*.js' , 'dom/**/*.js' , '*.js' ]
76+ . concat ( es6Tests . map ( function ( e ) { return 'test/' + e ; } ) ) ,
77+ tests : tests
78+ . concat ( conditionalBrowserLoaders )
79+ . map ( function ( e ) { return 'test/' + e ; } ) ,
80+ extensions : [ busterAmd ]
81+ } ;
0 commit comments