]> source.dussan.org Git - jquery.git/commitdiff
Tests: Move promise/A+ adapters for tests to dedicated folder
authorOleg Gaidarenko <markelog@gmail.com>
Sat, 11 Jun 2016 07:30:12 +0000 (10:30 +0300)
committerOleg Gaidarenko <markelog@gmail.com>
Sat, 11 Jun 2016 07:39:51 +0000 (10:39 +0300)
build/tasks/promises_aplus_tests.js
test/node_smoke_tests/.eslintrc
test/promises_aplus_adapter_deferred.js [deleted file]
test/promises_aplus_adapter_when.js [deleted file]
test/promises_aplus_adapters/.eslintrc [new file with mode: 0644]
test/promises_aplus_adapters/deferred.js [new file with mode: 0644]
test/promises_aplus_adapters/when.js [new file with mode: 0644]

index c4fb86d4c27e5e51bcba541f91a9ca7a5e3db48a..a0118d1f03cff8e78d8613bd428bc07ff5a85d93 100644 (file)
@@ -5,19 +5,19 @@ module.exports = function( grunt ) {
        var spawnTest = require( "./lib/spawn_test.js" );
 
        grunt.registerTask( "promises_aplus_tests",
-               [ "promises_aplus_tests_deferred", "promises_aplus_tests_when" ] );
+               [ "promises_aplus_tests:deferred", "promises_aplus_tests:when" ] );
 
-       grunt.registerTask( "promises_aplus_tests_deferred", function() {
+       grunt.registerTask( "promises_aplus_tests:deferred", function() {
                spawnTest( this.async(),
                        "./node_modules/.bin/promises-aplus-tests",
-                       "test/promises_aplus_adapter_deferred.js"
+                       "test/promises_aplus_adapters/deferred.js"
                );
        } );
 
-       grunt.registerTask( "promises_aplus_tests_when", function() {
+       grunt.registerTask( "promises_aplus_tests:when", function() {
                spawnTest( this.async(),
                        "./node_modules/.bin/promises-aplus-tests",
-                       "test/promises_aplus_adapter_when.js"
+                       "test/promises_aplus_adapters/when.js"
                );
        } );
 };
index 11368d984c18300f554632604a44edceec3127e5..282933c1ae2ef37cf2773ae3c5453398efa1878b 100644 (file)
@@ -2,6 +2,9 @@
        "env": {
                "node": true
        },
+       "parserOptions": {
+               "ecmaVersion": 6
+       },
        "extends": "../.eslintrc",
        "root": true
 }
diff --git a/test/promises_aplus_adapter_deferred.js b/test/promises_aplus_adapter_deferred.js
deleted file mode 100644 (file)
index c7440b9..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/* jshint node: true */
-
-"use strict";
-
-require( "jsdom" ).env( "", function( errors, window ) {
-       if ( errors ) {
-               console.error( errors );
-               return;
-       }
-
-       var jQuery = require( ".." )( window );
-
-       exports.deferred = function() {
-               var deferred = jQuery.Deferred();
-
-               return {
-                       promise: deferred.promise(),
-                       resolve: deferred.resolve.bind( deferred ),
-                       reject: deferred.reject.bind( deferred )
-               };
-       };
-} );
diff --git a/test/promises_aplus_adapter_when.js b/test/promises_aplus_adapter_when.js
deleted file mode 100644 (file)
index 0a5ec67..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-/* jshint node: true */
-
-"use strict";
-
-require( "jsdom" ).env( "", function( errors, window ) {
-       if ( errors ) {
-               console.error( errors );
-               return;
-       }
-
-       var jQuery = require( ".." )( window );
-
-       exports.deferred = function() {
-               var adopted, promised,
-                       obj = {
-                               resolve: function() {
-                                       if ( !adopted ) {
-                                               adopted = jQuery.when.apply( jQuery, arguments );
-                                               if ( promised ) {
-                                                       adopted.then( promised.resolve, promised.reject );
-                                               }
-                                       }
-                                       return adopted;
-                               },
-                               reject: function( value ) {
-                                       if ( !adopted ) {
-                                               adopted = jQuery.when( jQuery.Deferred().reject( value ) );
-                                               if ( promised ) {
-                                                       adopted.then( promised.resolve, promised.reject );
-                                               }
-                                       }
-                                       return adopted;
-                               },
-
-                               // A manually-constructed thenable that works even if calls precede resolve/reject
-                               promise: {
-                                       then: function() {
-                                               if ( !adopted ) {
-                                                       if ( !promised ) {
-                                                               promised = jQuery.Deferred();
-                                                       }
-                                                       return promised.then.apply( promised, arguments );
-                                               }
-                                               return adopted.then.apply( adopted, arguments );
-                                       }
-                               }
-                       };
-
-               return obj;
-       };
-} );
diff --git a/test/promises_aplus_adapters/.eslintrc b/test/promises_aplus_adapters/.eslintrc
new file mode 100644 (file)
index 0000000..11368d9
--- /dev/null
@@ -0,0 +1,7 @@
+{
+       "env": {
+               "node": true
+       },
+       "extends": "../.eslintrc",
+       "root": true
+}
diff --git a/test/promises_aplus_adapters/deferred.js b/test/promises_aplus_adapters/deferred.js
new file mode 100644 (file)
index 0000000..31af166
--- /dev/null
@@ -0,0 +1,20 @@
+"use strict";
+
+require( "jsdom" ).env( "", function( errors, window ) {
+       if ( errors ) {
+               console.error( errors );
+               return;
+       }
+
+       var jQuery = require( "../../" )( window );
+
+       module.exports.deferred = function() {
+               var deferred = jQuery.Deferred();
+
+               return {
+                       promise: deferred.promise(),
+                       resolve: deferred.resolve.bind( deferred ),
+                       reject: deferred.reject.bind( deferred )
+               };
+       };
+} );
diff --git a/test/promises_aplus_adapters/when.js b/test/promises_aplus_adapters/when.js
new file mode 100644 (file)
index 0000000..adde1a1
--- /dev/null
@@ -0,0 +1,49 @@
+"use strict";
+
+require( "jsdom" ).env( "", function( errors, window ) {
+       if ( errors ) {
+               console.error( errors );
+               return;
+       }
+
+       var jQuery = require( "../../" )( window );
+
+       module.exports.deferred = function() {
+               var adopted, promised,
+                       obj = {
+                               resolve: function() {
+                                       if ( !adopted ) {
+                                               adopted = jQuery.when.apply( jQuery, arguments );
+                                               if ( promised ) {
+                                                       adopted.then( promised.resolve, promised.reject );
+                                               }
+                                       }
+                                       return adopted;
+                               },
+                               reject: function( value ) {
+                                       if ( !adopted ) {
+                                               adopted = jQuery.when( jQuery.Deferred().reject( value ) );
+                                               if ( promised ) {
+                                                       adopted.then( promised.resolve, promised.reject );
+                                               }
+                                       }
+                                       return adopted;
+                               },
+
+                               // A manually-constructed thenable that works even if calls precede resolve/reject
+                               promise: {
+                                       then: function() {
+                                               if ( !adopted ) {
+                                                       if ( !promised ) {
+                                                               promised = jQuery.Deferred();
+                                                       }
+                                                       return promised.then.apply( promised, arguments );
+                                               }
+                                               return adopted.then.apply( adopted, arguments );
+                                       }
+                               }
+                       };
+
+               return obj;
+       };
+} );