aboutsummaryrefslogtreecommitdiffstats
path: root/test/unit/deprecated.js
diff options
context:
space:
mode:
authorJason Bedard <jason+github@jbedard.ca>2018-01-14 00:46:20 -0800
committerTimmy Willison <4timmywil@gmail.com>2018-01-16 10:39:08 -0500
commit1ea092a54b00aa4d902f4e22ada3854d195d4a18 (patch)
tree705d445aa449743e06e6354bb3f746076700e31f /test/unit/deprecated.js
parent91fb18190e5ab9821e3c74b6aecbb5d197c6c5f6 (diff)
downloadjquery-1ea092a54b00aa4d902f4e22ada3854d195d4a18.tar.gz
jquery-1ea092a54b00aa4d902f4e22ada3854d195d4a18.zip
Core: deprecate jQuery.type
Fixes gh-3605 Close gh-3895
Diffstat (limited to 'test/unit/deprecated.js')
-rw-r--r--test/unit/deprecated.js46
1 files changed, 42 insertions, 4 deletions
diff --git a/test/unit/deprecated.js b/test/unit/deprecated.js
index 007b3f13f..aaab68beb 100644
--- a/test/unit/deprecated.js
+++ b/test/unit/deprecated.js
@@ -242,14 +242,52 @@ QUnit.test( "jQuery.nodeName", function( assert ) {
} );
-QUnit.test( "core", function( assert ) {
+QUnit.test( "type", function( assert ) {
+ assert.expect( 28 );
+
+ assert.equal( jQuery.type( null ), "null", "null" );
+ assert.equal( jQuery.type( undefined ), "undefined", "undefined" );
+ assert.equal( jQuery.type( true ), "boolean", "Boolean" );
+ assert.equal( jQuery.type( false ), "boolean", "Boolean" );
+ assert.equal( jQuery.type( Boolean( true ) ), "boolean", "Boolean" );
+ assert.equal( jQuery.type( 0 ), "number", "Number" );
+ assert.equal( jQuery.type( 1 ), "number", "Number" );
+ assert.equal( jQuery.type( Number( 1 ) ), "number", "Number" );
+ assert.equal( jQuery.type( "" ), "string", "String" );
+ assert.equal( jQuery.type( "a" ), "string", "String" );
+ assert.equal( jQuery.type( String( "a" ) ), "string", "String" );
+ assert.equal( jQuery.type( {} ), "object", "Object" );
+ assert.equal( jQuery.type( /foo/ ), "regexp", "RegExp" );
+ assert.equal( jQuery.type( new RegExp( "asdf" ) ), "regexp", "RegExp" );
+ assert.equal( jQuery.type( [ 1 ] ), "array", "Array" );
+ assert.equal( jQuery.type( new Date() ), "date", "Date" );
+ assert.equal( jQuery.type( new Function( "return;" ) ), "function", "Function" );
+ assert.equal( jQuery.type( function() {} ), "function", "Function" );
+ assert.equal( jQuery.type( new Error() ), "error", "Error" );
+ assert.equal( jQuery.type( window ), "object", "Window" );
+ assert.equal( jQuery.type( document ), "object", "Document" );
+ assert.equal( jQuery.type( document.body ), "object", "Element" );
+ assert.equal( jQuery.type( document.createTextNode( "foo" ) ), "object", "TextNode" );
+ assert.equal( jQuery.type( document.getElementsByTagName( "*" ) ), "object", "NodeList" );
+
+ // Avoid Lint complaints
+ var MyString = String,
+ MyNumber = Number,
+ MyBoolean = Boolean,
+ MyObject = Object;
+ assert.equal( jQuery.type( new MyBoolean( true ) ), "boolean", "Boolean" );
+ assert.equal( jQuery.type( new MyNumber( 1 ) ), "number", "Number" );
+ assert.equal( jQuery.type( new MyString( "a" ) ), "string", "String" );
+ assert.equal( jQuery.type( new MyObject() ), "object", "Object" );
+} );
+
+QUnit[ typeof Symbol === "function" ? "test" : "skip" ]( "type for `Symbol`", function( assert ) {
assert.expect( 2 );
- assert.ok( jQuery.isFunction( jQuery.noop ), "jQuery.isFunction(jQuery.noop)" );
- assert.ok( !jQuery.isFunction( 2 ), "jQuery.isFunction(Number)" );
+ assert.equal( jQuery.type( Symbol() ), "symbol", "Symbol" );
+ assert.equal( jQuery.type( Object( Symbol() ) ), "symbol", "Symbol" );
} );
-
QUnit.test( "isFunction", function( assert ) {
assert.expect( 20 );