Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
J
jquery
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
夏彬
jquery
Commits
b8d0c071
Commit
b8d0c071
authored
Dec 02, 2009
by
jeresig
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added some isObjectLiteral tests.
parent
e277e6ed
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
45 additions
and
0 deletions
+45
-0
core.js
test/unit/core.js
+45
-0
No files found.
test/unit/core.js
View file @
b8d0c071
...
...
@@ -200,6 +200,51 @@ test("trim", function() {
equals
(
jQuery
.
trim
(
" "
+
nbsp
+
"hello "
+
nbsp
+
" "
),
"hello"
,
" "
);
});
test
(
"isObjectLiteral"
,
function
()
{
expect
(
7
);
stop
();
// The use case that we want to match
ok
(
jQuery
.
isObjectLiteral
({}),
"{}"
);
// Instantiated objects shouldn't be matched
ok
(
!
jQuery
.
isObjectLiteral
(
new
Date
),
"new Date"
);
var
fn
=
function
(){};
// Functions shouldn't be matched
ok
(
!
jQuery
.
isObjectLiteral
(
fn
),
"fn"
);
// Again, instantiated objects shouldn't be matched
ok
(
!
jQuery
.
isObjectLiteral
(
new
fn
),
"new fn (no methods)"
);
// Makes the function a little more realistic
// (and harder to detect, incidentally)
fn
.
prototype
=
{
someMethod
:
function
(){}};
// Again, instantiated objects shouldn't be matched
ok
(
!
jQuery
.
isObjectLiteral
(
new
fn
),
"new fn"
);
// DOM Element
ok
(
!
jQuery
.
isObjectLiteral
(
document
.
createElement
(
"div"
)),
"DOM Element"
);
var
iframe
=
document
.
createElement
(
"iframe"
);
document
.
body
.
appendChild
(
iframe
);
window
.
iframeDone
=
function
(
otherObject
){
// Objects from other windows should be matched
ok
(
jQuery
.
isObjectLiteral
(
new
otherObject
),
"new otherObject"
);
document
.
body
.
removeChild
(
iframe
);
start
();
};
var
doc
=
iframe
.
contentDocument
||
iframe
.
contentWindow
.
document
;
doc
.
open
();
doc
.
write
(
"<body onload='window.top.iframeDone(Object);'>"
);
doc
.
close
();
});
test
(
"isFunction"
,
function
()
{
expect
(
19
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment