Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
renderjs
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
renderjs
Commits
229d2f01
Commit
229d2f01
authored
Aug 04, 2017
by
Romain Courteaud
🐸
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Test: add expect for all tests
parent
84bcf0e9
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
120 additions
and
5 deletions
+120
-5
test/renderjs_test.js
test/renderjs_test.js
+120
-5
No files found.
test/renderjs_test.js
View file @
229d2f01
...
@@ -369,6 +369,7 @@
...
@@ -369,6 +369,7 @@
});
});
stop
();
stop
();
expect
(
2
);
gadget
.
__sub_gadget_dict
=
{};
gadget
.
__sub_gadget_dict
=
{};
cancel_queue
=
gadget
.
declareGadget
(
url
);
cancel_queue
=
gadget
.
declareGadget
(
url
);
return
new
RSVP
.
Queue
()
return
new
RSVP
.
Queue
()
...
@@ -419,6 +420,7 @@
...
@@ -419,6 +420,7 @@
},
"
foo
"
]);
},
"
foo
"
]);
stop
();
stop
();
expect
(
2
);
renderJS
.
declareGadgetKlass
(
url
)
renderJS
.
declareGadgetKlass
(
url
)
.
then
(
function
()
{
.
then
(
function
()
{
ok
(
false
,
"
404 should fail
"
);
ok
(
false
,
"
404 should fail
"
);
...
@@ -441,6 +443,7 @@
...
@@ -441,6 +443,7 @@
},
"
foo
"
]);
},
"
foo
"
]);
stop
();
stop
();
expect
(
2
);
renderJS
.
declareGadgetKlass
(
url
)
renderJS
.
declareGadgetKlass
(
url
)
.
then
(
function
()
{
.
then
(
function
()
{
ok
(
false
,
"
text/plain should fail
"
);
ok
(
false
,
"
text/plain should fail
"
);
...
@@ -469,6 +472,7 @@
...
@@ -469,6 +472,7 @@
mock
.
expects
(
"
parseGadgetHTMLDocument
"
).
once
().
throws
();
mock
.
expects
(
"
parseGadgetHTMLDocument
"
).
once
().
throws
();
stop
();
stop
();
expect
(
1
);
renderJS
.
declareGadgetKlass
(
url
)
renderJS
.
declareGadgetKlass
(
url
)
.
then
(
function
()
{
.
then
(
function
()
{
ok
(
false
,
"
Non parsable HTML should fail
"
);
ok
(
false
,
"
Non parsable HTML should fail
"
);
...
@@ -493,6 +497,7 @@
...
@@ -493,6 +497,7 @@
spy
=
sinon
.
spy
(
renderJS
,
"
parseGadgetHTMLDocument
"
);
spy
=
sinon
.
spy
(
renderJS
,
"
parseGadgetHTMLDocument
"
);
stop
();
stop
();
expect
(
1
);
renderJS
.
declareGadgetKlass
(
url
)
renderJS
.
declareGadgetKlass
(
url
)
.
then
(
function
()
{
.
then
(
function
()
{
equal
(
spy
.
args
[
0
][
1
],
url
);
equal
(
spy
.
args
[
0
][
1
],
url
);
...
@@ -519,6 +524,7 @@
...
@@ -519,6 +524,7 @@
);
);
stop
();
stop
();
expect
(
7
);
renderJS
.
declareGadgetKlass
(
url
)
renderJS
.
declareGadgetKlass
(
url
)
.
then
(
function
(
Klass
)
{
.
then
(
function
(
Klass
)
{
var
instance
;
var
instance
;
...
@@ -560,6 +566,7 @@
...
@@ -560,6 +566,7 @@
);
);
stop
();
stop
();
expect
(
1
);
renderJS
.
declareGadgetKlass
(
url
)
renderJS
.
declareGadgetKlass
(
url
)
.
then
(
function
(
Klass1
)
{
.
then
(
function
(
Klass1
)
{
klass1
=
Klass1
;
klass1
=
Klass1
;
...
@@ -588,6 +595,7 @@
...
@@ -588,6 +595,7 @@
},
"
<html></html>
"
]);
},
"
<html></html>
"
]);
stop
();
stop
();
expect
(
5
);
renderJS
.
declareGadgetKlass
(
url
)
renderJS
.
declareGadgetKlass
(
url
)
.
then
(
function
(
Klass
)
{
.
then
(
function
(
Klass
)
{
var
instance
;
var
instance
;
...
@@ -621,6 +629,7 @@
...
@@ -621,6 +629,7 @@
var
url
=
'
http://0.0.0.0/bar
'
;
var
url
=
'
http://0.0.0.0/bar
'
;
stop
();
stop
();
expect
(
2
);
renderJS
.
declareJS
(
url
,
document
.
head
)
renderJS
.
declareJS
(
url
,
document
.
head
)
.
then
(
function
()
{
.
then
(
function
()
{
ok
(
false
,
"
404 should fail
"
);
ok
(
false
,
"
404 should fail
"
);
...
@@ -639,6 +648,7 @@
...
@@ -639,6 +648,7 @@
var
url
=
'
http://0.0.0.0/bar2
'
;
var
url
=
'
http://0.0.0.0/bar2
'
;
stop
();
stop
();
expect
(
2
);
renderJS
.
declareJS
(
url
,
document
.
head
)
renderJS
.
declareJS
(
url
,
document
.
head
)
.
then
(
function
()
{
.
then
(
function
()
{
return
renderJS
.
declareJS
(
url
);
return
renderJS
.
declareJS
(
url
);
...
@@ -662,13 +672,15 @@
...
@@ -662,13 +672,15 @@
previousonerror
=
window
.
onerror
;
previousonerror
=
window
.
onerror
;
stop
();
stop
();
expect
(
1
);
window
.
onerror
=
undefined
;
window
.
onerror
=
undefined
;
renderJS
.
declareJS
(
url
,
document
.
head
)
renderJS
.
declareJS
(
url
,
document
.
head
)
.
then
(
function
(
value
,
textStatus
,
jqXHR
)
{
.
then
(
function
(
value
,
textStatus
,
jqXHR
)
{
ok
(
ok
,
"
Non JS mime type should load
"
);
ok
(
ok
,
"
Non JS mime type should load
"
);
})
})
.
fail
(
function
(
jqXHR
)
{
.
fail
(
function
(
jqXHR
)
{
ok
(
false
,
jqXHR
);
// Chrome does not consider this as error
ok
(
ok
,
jqXHR
);
})
})
.
always
(
function
()
{
.
always
(
function
()
{
window
.
onerror
=
previousonerror
;
window
.
onerror
=
previousonerror
;
...
@@ -683,6 +695,7 @@
...
@@ -683,6 +695,7 @@
"
= 'JS fetched and loaded';
"
);
"
= 'JS fetched and loaded';
"
);
stop
();
stop
();
expect
(
1
);
renderJS
.
declareJS
(
url
,
document
.
head
)
renderJS
.
declareJS
(
url
,
document
.
head
)
.
then
(
function
()
{
.
then
(
function
()
{
equal
(
equal
(
...
@@ -705,6 +718,7 @@
...
@@ -705,6 +718,7 @@
previousonerror
=
window
.
onerror
;
previousonerror
=
window
.
onerror
;
stop
();
stop
();
expect
(
1
);
window
.
onerror
=
undefined
;
window
.
onerror
=
undefined
;
renderJS
.
declareJS
(
url
,
document
.
head
)
renderJS
.
declareJS
(
url
,
document
.
head
)
.
then
(
function
(
aaa
)
{
.
then
(
function
(
aaa
)
{
...
@@ -726,6 +740,7 @@
...
@@ -726,6 +740,7 @@
"
= 'JS not fetched twice';
"
);
"
= 'JS not fetched twice';
"
);
stop
();
stop
();
expect
(
2
);
renderJS
.
declareJS
(
url
,
document
.
head
)
renderJS
.
declareJS
(
url
,
document
.
head
)
.
then
(
function
()
{
.
then
(
function
()
{
equal
(
equal
(
...
@@ -760,6 +775,7 @@
...
@@ -760,6 +775,7 @@
var
url
=
'
foo//://bar
'
;
var
url
=
'
foo//://bar
'
;
stop
();
stop
();
expect
(
2
);
renderJS
.
declareCSS
(
url
,
document
.
head
)
renderJS
.
declareCSS
(
url
,
document
.
head
)
.
then
(
function
()
{
.
then
(
function
()
{
// IE accept the css
// IE accept the css
...
@@ -780,13 +796,13 @@
...
@@ -780,13 +796,13 @@
window
.
btoa
(
"
= = =
"
);
window
.
btoa
(
"
= = =
"
);
stop
();
stop
();
expect
(
1
);
renderJS
.
declareCSS
(
url
,
document
.
head
)
renderJS
.
declareCSS
(
url
,
document
.
head
)
.
then
(
function
(
value
,
textStatus
,
jqXHR
)
{
.
then
(
function
(
value
,
textStatus
,
jqXHR
)
{
// Chrome accept the css
// Chrome accept the css
ok
(
true
,
"
Non CSS mime type should load
"
);
ok
(
true
,
"
Non CSS mime type should load
"
);
})
})
.
fail
(
function
(
e
)
{
.
fail
(
function
(
e
)
{
equal
(
e
.
type
,
"
error
"
);
equal
(
e
.
target
.
getAttribute
(
"
href
"
),
url
);
equal
(
e
.
target
.
getAttribute
(
"
href
"
),
url
);
})
})
.
always
(
function
()
{
.
always
(
function
()
{
...
@@ -800,6 +816,7 @@
...
@@ -800,6 +816,7 @@
window
.
btoa
(
"
#qunit-fixture {background-color: red;}
"
);
window
.
btoa
(
"
#qunit-fixture {background-color: red;}
"
);
stop
();
stop
();
expect
(
2
);
renderJS
.
declareCSS
(
url
,
document
.
head
)
renderJS
.
declareCSS
(
url
,
document
.
head
)
.
then
(
function
()
{
.
then
(
function
()
{
var
result
=
document
.
querySelectorAll
(
"
link[href='
"
+
url
+
"
']
"
);
var
result
=
document
.
querySelectorAll
(
"
link[href='
"
+
url
+
"
']
"
);
...
@@ -827,6 +844,7 @@
...
@@ -827,6 +844,7 @@
window
.
btoa
(
"
throw new Error('foo');
"
);
window
.
btoa
(
"
throw new Error('foo');
"
);
stop
();
stop
();
expect
(
1
);
renderJS
.
declareCSS
(
url
,
document
.
head
)
renderJS
.
declareCSS
(
url
,
document
.
head
)
.
then
(
function
()
{
.
then
(
function
()
{
// Chrome does not consider this as error
// Chrome does not consider this as error
...
@@ -846,6 +864,7 @@
...
@@ -846,6 +864,7 @@
window
.
btoa
(
"
#qunit-fixture {background-color: blue;}
"
);
window
.
btoa
(
"
#qunit-fixture {background-color: blue;}
"
);
stop
();
stop
();
expect
(
4
);
renderJS
.
declareCSS
(
url
,
document
.
head
)
renderJS
.
declareCSS
(
url
,
document
.
head
)
.
then
(
function
()
{
.
then
(
function
()
{
equal
(
equal
(
...
@@ -919,6 +938,7 @@
...
@@ -919,6 +938,7 @@
);
);
stop
();
stop
();
expect
(
1
);
renderJS
.
declareGadgetKlass
(
url
)
renderJS
.
declareGadgetKlass
(
url
)
.
then
(
function
(
Klass1
)
{
.
then
(
function
(
Klass1
)
{
klass1
=
Klass1
;
klass1
=
Klass1
;
...
@@ -948,6 +968,7 @@
...
@@ -948,6 +968,7 @@
"
= 'JS not fetched twice';
"
);
"
= 'JS not fetched twice';
"
);
stop
();
stop
();
expect
(
2
);
renderJS
.
declareJS
(
url
,
document
.
head
)
renderJS
.
declareJS
(
url
,
document
.
head
)
.
then
(
function
()
{
.
then
(
function
()
{
renderJS
.
clearGadgetKlassList
();
renderJS
.
clearGadgetKlassList
();
...
@@ -980,6 +1001,7 @@
...
@@ -980,6 +1001,7 @@
count
=
document
.
querySelectorAll
(
"
link[rel=stylesheet]
"
).
length
;
count
=
document
.
querySelectorAll
(
"
link[rel=stylesheet]
"
).
length
;
stop
();
stop
();
expect
(
2
);
renderJS
.
declareCSS
(
url
,
document
.
head
)
renderJS
.
declareCSS
(
url
,
document
.
head
)
.
then
(
function
()
{
.
then
(
function
()
{
renderJS
.
clearGadgetKlassList
();
renderJS
.
clearGadgetKlassList
();
...
@@ -1054,6 +1076,7 @@
...
@@ -1054,6 +1076,7 @@
var
gadget
=
new
RenderJSGadget
();
var
gadget
=
new
RenderJSGadget
();
gadget
.
__interface_list
=
"
foo
"
;
gadget
.
__interface_list
=
"
foo
"
;
stop
();
stop
();
expect
(
1
);
gadget
.
getInterfaceList
()
gadget
.
getInterfaceList
()
.
then
(
function
(
result
)
{
.
then
(
function
(
result
)
{
equal
(
result
,
"
foo
"
);
equal
(
result
,
"
foo
"
);
...
@@ -1070,6 +1093,7 @@
...
@@ -1070,6 +1093,7 @@
// Check that getInterfaceList return a Promise
// Check that getInterfaceList return a Promise
var
gadget
=
new
RenderJSGadget
();
var
gadget
=
new
RenderJSGadget
();
stop
();
stop
();
expect
(
1
);
gadget
.
getInterfaceList
()
gadget
.
getInterfaceList
()
.
then
(
function
(
result
)
{
.
then
(
function
(
result
)
{
deepEqual
(
result
,
[]);
deepEqual
(
result
,
[]);
...
@@ -1092,6 +1116,7 @@
...
@@ -1092,6 +1116,7 @@
var
gadget
=
new
RenderJSGadget
();
var
gadget
=
new
RenderJSGadget
();
gadget
.
__required_css_list
=
"
foo
"
;
gadget
.
__required_css_list
=
"
foo
"
;
stop
();
stop
();
expect
(
1
);
gadget
.
getRequiredCSSList
()
gadget
.
getRequiredCSSList
()
.
then
(
function
(
result
)
{
.
then
(
function
(
result
)
{
equal
(
result
,
"
foo
"
);
equal
(
result
,
"
foo
"
);
...
@@ -1105,6 +1130,7 @@
...
@@ -1105,6 +1130,7 @@
// Check that getRequiredCSSList return a Promise
// Check that getRequiredCSSList return a Promise
var
gadget
=
new
RenderJSGadget
();
var
gadget
=
new
RenderJSGadget
();
stop
();
stop
();
expect
(
1
);
gadget
.
getRequiredCSSList
()
gadget
.
getRequiredCSSList
()
.
then
(
function
(
result
)
{
.
then
(
function
(
result
)
{
deepEqual
(
result
,
[]);
deepEqual
(
result
,
[]);
...
@@ -1127,6 +1153,7 @@
...
@@ -1127,6 +1153,7 @@
var
gadget
=
new
RenderJSGadget
();
var
gadget
=
new
RenderJSGadget
();
gadget
.
__required_js_list
=
"
foo
"
;
gadget
.
__required_js_list
=
"
foo
"
;
stop
();
stop
();
expect
(
1
);
gadget
.
getRequiredJSList
()
gadget
.
getRequiredJSList
()
.
then
(
function
(
result
)
{
.
then
(
function
(
result
)
{
equal
(
result
,
"
foo
"
);
equal
(
result
,
"
foo
"
);
...
@@ -1140,6 +1167,7 @@
...
@@ -1140,6 +1167,7 @@
// Check that getRequiredJSList return a Promise
// Check that getRequiredJSList return a Promise
var
gadget
=
new
RenderJSGadget
();
var
gadget
=
new
RenderJSGadget
();
stop
();
stop
();
expect
(
1
);
gadget
.
getRequiredJSList
()
gadget
.
getRequiredJSList
()
.
then
(
function
(
result
)
{
.
then
(
function
(
result
)
{
deepEqual
(
result
,
[]);
deepEqual
(
result
,
[]);
...
@@ -1162,6 +1190,7 @@
...
@@ -1162,6 +1190,7 @@
var
gadget
=
new
RenderJSGadget
();
var
gadget
=
new
RenderJSGadget
();
gadget
.
__path
=
"
foo
"
;
gadget
.
__path
=
"
foo
"
;
stop
();
stop
();
expect
(
1
);
gadget
.
getPath
()
gadget
.
getPath
()
.
then
(
function
(
result
)
{
.
then
(
function
(
result
)
{
equal
(
result
,
"
foo
"
);
equal
(
result
,
"
foo
"
);
...
@@ -1175,6 +1204,7 @@
...
@@ -1175,6 +1204,7 @@
// Check that getPath return a Promise
// Check that getPath return a Promise
var
gadget
=
new
RenderJSGadget
();
var
gadget
=
new
RenderJSGadget
();
stop
();
stop
();
expect
(
1
);
gadget
.
getPath
()
gadget
.
getPath
()
.
then
(
function
(
result
)
{
.
then
(
function
(
result
)
{
equal
(
result
,
""
);
equal
(
result
,
""
);
...
@@ -1197,6 +1227,7 @@
...
@@ -1197,6 +1227,7 @@
var
gadget
=
new
RenderJSGadget
();
var
gadget
=
new
RenderJSGadget
();
gadget
.
__title
=
"
foo
"
;
gadget
.
__title
=
"
foo
"
;
stop
();
stop
();
expect
(
1
);
gadget
.
getTitle
()
gadget
.
getTitle
()
.
then
(
function
(
result
)
{
.
then
(
function
(
result
)
{
equal
(
result
,
"
foo
"
);
equal
(
result
,
"
foo
"
);
...
@@ -1210,6 +1241,7 @@
...
@@ -1210,6 +1241,7 @@
// Check that getTitle return a Promise
// Check that getTitle return a Promise
var
gadget
=
new
RenderJSGadget
();
var
gadget
=
new
RenderJSGadget
();
stop
();
stop
();
expect
(
1
);
gadget
.
getTitle
()
gadget
.
getTitle
()
.
then
(
function
(
result
)
{
.
then
(
function
(
result
)
{
equal
(
result
,
""
);
equal
(
result
,
""
);
...
@@ -1232,6 +1264,7 @@
...
@@ -1232,6 +1264,7 @@
var
gadget
=
new
RenderJSGadget
();
var
gadget
=
new
RenderJSGadget
();
gadget
.
element
=
"
foo
"
;
gadget
.
element
=
"
foo
"
;
stop
();
stop
();
expect
(
1
);
gadget
.
getElement
()
gadget
.
getElement
()
.
then
(
function
(
result
)
{
.
then
(
function
(
result
)
{
equal
(
result
,
"
foo
"
);
equal
(
result
,
"
foo
"
);
...
@@ -1245,6 +1278,7 @@
...
@@ -1245,6 +1278,7 @@
// Check that getElement return a Promise
// Check that getElement return a Promise
var
gadget
=
new
RenderJSGadget
();
var
gadget
=
new
RenderJSGadget
();
stop
();
stop
();
expect
(
2
);
gadget
.
getElement
()
gadget
.
getElement
()
.
then
(
function
()
{
.
then
(
function
()
{
ok
(
false
,
"
getElement should fail
"
);
ok
(
false
,
"
getElement should fail
"
);
...
@@ -1270,6 +1304,7 @@
...
@@ -1270,6 +1304,7 @@
var
gadget
=
new
RenderJSGadget
();
var
gadget
=
new
RenderJSGadget
();
gadget
.
state
=
{
foo
:
'
bar
'
,
bar
:
'
foo
'
};
gadget
.
state
=
{
foo
:
'
bar
'
,
bar
:
'
foo
'
};
stop
();
stop
();
expect
(
1
);
gadget
.
changeState
({
bar
:
'
barbar
'
})
gadget
.
changeState
({
bar
:
'
barbar
'
})
.
then
(
function
()
{
.
then
(
function
()
{
deepEqual
(
gadget
.
state
,
{
foo
:
'
bar
'
,
bar
:
'
barbar
'
});
deepEqual
(
gadget
.
state
,
{
foo
:
'
bar
'
,
bar
:
'
barbar
'
});
...
@@ -1296,6 +1331,7 @@
...
@@ -1296,6 +1331,7 @@
});
});
};
};
stop
();
stop
();
expect
(
4
);
gadget
.
changeState
({
bar
:
'
barbar
'
})
gadget
.
changeState
({
bar
:
'
barbar
'
})
.
then
(
function
()
{
.
then
(
function
()
{
ok
(
callback_called
);
ok
(
callback_called
);
...
@@ -1316,6 +1352,7 @@
...
@@ -1316,6 +1352,7 @@
callback_called
=
true
;
callback_called
=
true
;
};
};
stop
();
stop
();
expect
(
1
);
gadget
.
changeState
({
bar
:
'
foo
'
})
gadget
.
changeState
({
bar
:
'
foo
'
})
.
then
(
function
()
{
.
then
(
function
()
{
ok
(
!
callback_called
);
ok
(
!
callback_called
);
...
@@ -1336,6 +1373,7 @@
...
@@ -1336,6 +1373,7 @@
callback_called
=
true
;
callback_called
=
true
;
};
};
stop
();
stop
();
expect
(
2
);
gadget
.
changeState
({})
gadget
.
changeState
({})
.
then
(
function
()
{
.
then
(
function
()
{
ok
(
!
callback_called
);
ok
(
!
callback_called
);
...
@@ -1356,7 +1394,6 @@
...
@@ -1356,7 +1394,6 @@
var
gadget
=
new
RenderJSGadget
(),
var
gadget
=
new
RenderJSGadget
(),
callback_count
=
0
;
callback_count
=
0
;
gadget
.
state
=
{};
gadget
.
state
=
{};
expect
(
6
);
gadget
.
__state_change_callback
=
function
(
modification_dict
)
{
gadget
.
__state_change_callback
=
function
(
modification_dict
)
{
if
(
callback_count
===
0
)
{
if
(
callback_count
===
0
)
{
callback_count
+=
1
;
callback_count
+=
1
;
...
@@ -1379,6 +1416,7 @@
...
@@ -1379,6 +1416,7 @@
}
}
};
};
stop
();
stop
();
expect
(
6
);
return
new
RSVP
.
all
([
return
new
RSVP
.
all
([
gadget
.
changeState
({
first
:
true
}),
gadget
.
changeState
({
first
:
true
}),
gadget
.
changeState
({
second
:
true
})
gadget
.
changeState
({
second
:
true
})
...
@@ -1399,7 +1437,6 @@
...
@@ -1399,7 +1437,6 @@
var
gadget
=
new
RenderJSGadget
(),
var
gadget
=
new
RenderJSGadget
(),
callback_count
=
0
;
callback_count
=
0
;
gadget
.
state
=
{};
gadget
.
state
=
{};
expect
(
7
);
gadget
.
__state_change_callback
=
function
(
modification_dict
)
{
gadget
.
__state_change_callback
=
function
(
modification_dict
)
{
if
(
callback_count
===
0
)
{
if
(
callback_count
===
0
)
{
callback_count
+=
1
;
callback_count
+=
1
;
...
@@ -1423,6 +1460,7 @@
...
@@ -1423,6 +1460,7 @@
}
}
};
};
stop
();
stop
();
expect
(
7
);
return
new
RSVP
.
all
([
return
new
RSVP
.
all
([
gadget
.
changeState
({
first
:
true
})
gadget
.
changeState
({
first
:
true
})
.
fail
(
function
(
error
)
{
.
fail
(
function
(
error
)
{
...
@@ -1444,13 +1482,13 @@
...
@@ -1444,13 +1482,13 @@
test
(
'
accumulate modification_dict on onStateChange error
'
,
function
()
{
test
(
'
accumulate modification_dict on onStateChange error
'
,
function
()
{
var
gadget
=
new
RenderJSGadget
();
var
gadget
=
new
RenderJSGadget
();
expect
(
13
);
gadget
.
state
=
{
a
:
'
b
'
,
foo
:
'
bar
'
,
bar
:
'
foo
'
};
gadget
.
state
=
{
a
:
'
b
'
,
foo
:
'
bar
'
,
bar
:
'
foo
'
};
gadget
.
__state_change_callback
=
function
(
modification_dict
)
{
gadget
.
__state_change_callback
=
function
(
modification_dict
)
{
deepEqual
(
modification_dict
,
{
bar
:
'
barbar
'
});
deepEqual
(
modification_dict
,
{
bar
:
'
barbar
'
});
throw
new
Error
(
'
failure in onStateChange
'
);
throw
new
Error
(
'
failure in onStateChange
'
);
};
};
stop
();
stop
();
expect
(
13
);
gadget
.
changeState
({
bar
:
'
barbar
'
})
gadget
.
changeState
({
bar
:
'
barbar
'
})
.
then
(
function
()
{
.
then
(
function
()
{
ok
(
false
,
'
Expecting an error
'
);
ok
(
false
,
'
Expecting an error
'
);
...
@@ -1580,6 +1618,7 @@
...
@@ -1580,6 +1618,7 @@
};
};
stop
();
stop
();
expect
(
5
);
gadget
.
checkIfAqDynamicIsUndefined
(
"
foobar
"
,
"
barfoo
"
)
gadget
.
checkIfAqDynamicIsUndefined
(
"
foobar
"
,
"
barfoo
"
)
.
then
(
function
(
result
)
{
.
then
(
function
(
result
)
{
equal
(
result
,
"
FOO
"
);
equal
(
result
,
"
FOO
"
);
...
@@ -1610,6 +1649,7 @@
...
@@ -1610,6 +1649,7 @@
};
};
stop
();
stop
();
expect
(
2
);
gadget
.
checkIfAqParentThrowsError
()
gadget
.
checkIfAqParentThrowsError
()
.
fail
(
function
(
error
)
{
.
fail
(
function
(
error
)
{
equal
(
error
,
original_error
);
equal
(
error
,
original_error
);
...
@@ -1635,6 +1675,7 @@
...
@@ -1635,6 +1675,7 @@
gadget
=
new
Klass
();
gadget
=
new
Klass
();
stop
();
stop
();
expect
(
2
);
gadget
.
checkIfAqParentIsUndefined
()
gadget
.
checkIfAqParentIsUndefined
()
.
fail
(
function
(
error
)
{
.
fail
(
function
(
error
)
{
ok
(
error
instanceof
TypeError
);
ok
(
error
instanceof
TypeError
);
...
@@ -1796,6 +1837,7 @@
...
@@ -1796,6 +1837,7 @@
equal
(
Klass
.
prototype
.
testFoo
,
gadget
.
testFoo
);
equal
(
Klass
.
prototype
.
testFoo
,
gadget
.
testFoo
);
stop
();
stop
();
expect
(
6
);
// method can be called
// method can be called
gadget
.
testFoo
(
"
Bar
"
)
gadget
.
testFoo
(
"
Bar
"
)
.
then
(
function
(
param
)
{
.
then
(
function
(
param
)
{
...
@@ -1828,6 +1870,7 @@
...
@@ -1828,6 +1870,7 @@
// method can be called
// method can be called
stop
();
stop
();
expect
(
1
);
gadget
.
testFoo
(
"
Bar
"
)
gadget
.
testFoo
(
"
Bar
"
)
.
then
(
function
(
param
)
{
.
then
(
function
(
param
)
{
equal
(
param
,
"
Bar
"
);
equal
(
param
,
"
Bar
"
);
...
@@ -1858,6 +1901,7 @@
...
@@ -1858,6 +1901,7 @@
// method can be called
// method can be called
stop
();
stop
();
expect
(
1
);
gadget
.
testFoo
(
"
Bar
"
)
gadget
.
testFoo
(
"
Bar
"
)
.
then
(
function
()
{
.
then
(
function
()
{
ok
(
false
,
"
Callback promise is rejected
"
);
ok
(
false
,
"
Callback promise is rejected
"
);
...
@@ -2125,6 +2169,7 @@
...
@@ -2125,6 +2169,7 @@
},
"
<html><body></body></html>
"
]);
},
"
<html><body></body></html>
"
]);
stop
();
stop
();
expect
(
6
);
renderJS
.
declareGadgetKlass
(
html_url
)
renderJS
.
declareGadgetKlass
(
html_url
)
.
then
(
function
(
Klass
)
{
.
then
(
function
(
Klass
)
{
declareServiceToCheck
(
Klass
,
service1
);
declareServiceToCheck
(
Klass
,
service1
);
...
@@ -2166,6 +2211,7 @@
...
@@ -2166,6 +2211,7 @@
document
.
getElementById
(
'
qunit-fixture
'
).
innerHTML
=
"
<div></div>
"
;
document
.
getElementById
(
'
qunit-fixture
'
).
innerHTML
=
"
<div></div>
"
;
stop
();
stop
();
expect
(
6
);
renderJS
.
declareGadgetKlass
(
html_url
)
renderJS
.
declareGadgetKlass
(
html_url
)
.
then
(
function
(
Klass
)
{
.
then
(
function
(
Klass
)
{
declareServiceToCheck
(
Klass
,
service1
);
declareServiceToCheck
(
Klass
,
service1
);
...
@@ -2209,6 +2255,7 @@
...
@@ -2209,6 +2255,7 @@
document
.
getElementById
(
'
qunit-fixture
'
).
innerHTML
=
"
<div></div>
"
;
document
.
getElementById
(
'
qunit-fixture
'
).
innerHTML
=
"
<div></div>
"
;
stop
();
stop
();
expect
(
6
);
renderJS
.
declareGadgetKlass
(
html_url
)
renderJS
.
declareGadgetKlass
(
html_url
)
.
then
(
function
(
Klass
)
{
.
then
(
function
(
Klass
)
{
declareServiceToCheck
(
Klass
,
service1
);
declareServiceToCheck
(
Klass
,
service1
);
...
@@ -2255,6 +2302,7 @@
...
@@ -2255,6 +2302,7 @@
document
.
getElementById
(
'
qunit-fixture
'
).
innerHTML
=
""
;
document
.
getElementById
(
'
qunit-fixture
'
).
innerHTML
=
""
;
stop
();
stop
();
expect
(
6
);
renderJS
.
declareGadgetKlass
(
html_url
)
renderJS
.
declareGadgetKlass
(
html_url
)
.
then
(
function
(
Klass
)
{
.
then
(
function
(
Klass
)
{
declareServiceToCheck
(
Klass
,
service1
);
declareServiceToCheck
(
Klass
,
service1
);
...
@@ -2300,6 +2348,7 @@
...
@@ -2300,6 +2348,7 @@
document
.
getElementById
(
'
qunit-fixture
'
).
innerHTML
=
"
<div></div>
"
;
document
.
getElementById
(
'
qunit-fixture
'
).
innerHTML
=
"
<div></div>
"
;
stop
();
stop
();
expect
(
6
);
renderJS
.
declareGadgetKlass
(
html_url
)
renderJS
.
declareGadgetKlass
(
html_url
)
.
then
(
function
(
Klass
)
{
.
then
(
function
(
Klass
)
{
declareServiceToCheck
(
Klass
,
service1
);
declareServiceToCheck
(
Klass
,
service1
);
...
@@ -2351,6 +2400,7 @@
...
@@ -2351,6 +2400,7 @@
document
.
getElementById
(
'
qunit-fixture
'
).
innerHTML
=
""
;
document
.
getElementById
(
'
qunit-fixture
'
).
innerHTML
=
""
;
stop
();
stop
();
expect
(
6
);
renderJS
.
declareGadgetKlass
(
html_url
)
renderJS
.
declareGadgetKlass
(
html_url
)
.
then
(
function
(
Klass
)
{
.
then
(
function
(
Klass
)
{
declareServiceToCheck
(
Klass
,
service1
);
declareServiceToCheck
(
Klass
,
service1
);
...
@@ -2403,6 +2453,7 @@
...
@@ -2403,6 +2453,7 @@
document
.
getElementById
(
'
qunit-fixture
'
).
innerHTML
=
"
<div></div>
"
;
document
.
getElementById
(
'
qunit-fixture
'
).
innerHTML
=
"
<div></div>
"
;
stop
();
stop
();
expect
(
6
);
renderJS
.
declareGadgetKlass
(
html_url
)
renderJS
.
declareGadgetKlass
(
html_url
)
.
then
(
function
(
Klass
)
{
.
then
(
function
(
Klass
)
{
declareServiceToCheck
(
Klass
,
service1
);
declareServiceToCheck
(
Klass
,
service1
);
...
@@ -2476,6 +2527,7 @@
...
@@ -2476,6 +2527,7 @@
document
.
getElementById
(
'
qunit-fixture
'
).
innerHTML
=
"
<div></div>
"
;
document
.
getElementById
(
'
qunit-fixture
'
).
innerHTML
=
"
<div></div>
"
;
stop
();
stop
();
expect
(
2
);
renderJS
.
declareGadgetKlass
(
html_url
)
renderJS
.
declareGadgetKlass
(
html_url
)
.
then
(
function
(
Klass
)
{
.
then
(
function
(
Klass
)
{
...
@@ -2534,6 +2586,7 @@
...
@@ -2534,6 +2586,7 @@
document
.
getElementById
(
'
qunit-fixture
'
).
innerHTML
=
"
<div></div>
"
;
document
.
getElementById
(
'
qunit-fixture
'
).
innerHTML
=
"
<div></div>
"
;
stop
();
stop
();
expect
(
3
);
renderJS
.
declareGadgetKlass
(
html_url
)
renderJS
.
declareGadgetKlass
(
html_url
)
.
then
(
function
(
Klass
)
{
.
then
(
function
(
Klass
)
{
...
@@ -2651,6 +2704,7 @@
...
@@ -2651,6 +2704,7 @@
document
.
getElementById
(
'
qunit-fixture
'
).
innerHTML
=
"
<div></div>
"
;
document
.
getElementById
(
'
qunit-fixture
'
).
innerHTML
=
"
<div></div>
"
;
stop
();
stop
();
expect
(
9
);
renderJS
.
declareGadgetKlass
(
html_url
)
renderJS
.
declareGadgetKlass
(
html_url
)
.
then
(
function
(
Klass
)
{
.
then
(
function
(
Klass
)
{
declareEventToCheck
(
Klass
,
service1
);
declareEventToCheck
(
Klass
,
service1
);
...
@@ -2778,6 +2832,7 @@
...
@@ -2778,6 +2832,7 @@
document
.
getElementById
(
'
qunit-fixture
'
).
innerHTML
=
"
<div></div>
"
;
document
.
getElementById
(
'
qunit-fixture
'
).
innerHTML
=
"
<div></div>
"
;
stop
();
stop
();
expect
(
9
);
renderJS
.
declareGadgetKlass
(
html_url
)
renderJS
.
declareGadgetKlass
(
html_url
)
.
then
(
function
(
Klass
)
{
.
then
(
function
(
Klass
)
{
declareTimeoutToCheck
(
Klass
,
service1
);
declareTimeoutToCheck
(
Klass
,
service1
);
...
@@ -2918,6 +2973,7 @@
...
@@ -2918,6 +2973,7 @@
},
"
<html><body></body></html>
"
]);
},
"
<html><body></body></html>
"
]);
stop
();
stop
();
expect
(
8
);
renderJS
.
declareGadgetKlass
(
html_url
)
renderJS
.
declareGadgetKlass
(
html_url
)
.
then
(
function
(
Klass
)
{
.
then
(
function
(
Klass
)
{
declareJobToCheck
(
Klass
,
'
runJob1
'
,
service1
);
declareJobToCheck
(
Klass
,
'
runJob1
'
,
service1
);
...
@@ -2969,6 +3025,7 @@
...
@@ -2969,6 +3025,7 @@
document
.
getElementById
(
'
qunit-fixture
'
).
innerHTML
=
"
<div></div>
"
;
document
.
getElementById
(
'
qunit-fixture
'
).
innerHTML
=
"
<div></div>
"
;
stop
();
stop
();
expect
(
8
);
renderJS
.
declareGadgetKlass
(
html_url
)
renderJS
.
declareGadgetKlass
(
html_url
)
.
then
(
function
(
Klass
)
{
.
then
(
function
(
Klass
)
{
declareJobToCheck
(
Klass
,
'
runJob1
'
,
service1
);
declareJobToCheck
(
Klass
,
'
runJob1
'
,
service1
);
...
@@ -3022,6 +3079,7 @@
...
@@ -3022,6 +3079,7 @@
document
.
getElementById
(
'
qunit-fixture
'
).
innerHTML
=
"
<div></div>
"
;
document
.
getElementById
(
'
qunit-fixture
'
).
innerHTML
=
"
<div></div>
"
;
stop
();
stop
();
expect
(
8
);
renderJS
.
declareGadgetKlass
(
html_url
)
renderJS
.
declareGadgetKlass
(
html_url
)
.
then
(
function
(
Klass
)
{
.
then
(
function
(
Klass
)
{
declareJobToCheck
(
Klass
,
'
runJob1
'
,
service1
);
declareJobToCheck
(
Klass
,
'
runJob1
'
,
service1
);
...
@@ -3077,6 +3135,7 @@
...
@@ -3077,6 +3135,7 @@
document
.
getElementById
(
'
qunit-fixture
'
).
innerHTML
=
"
<div></div>
"
;
document
.
getElementById
(
'
qunit-fixture
'
).
innerHTML
=
"
<div></div>
"
;
stop
();
stop
();
expect
(
8
);
renderJS
.
declareGadgetKlass
(
html_url
)
renderJS
.
declareGadgetKlass
(
html_url
)
.
then
(
function
(
Klass
)
{
.
then
(
function
(
Klass
)
{
declareJobToCheck
(
Klass
,
'
runJob1
'
,
service1
);
declareJobToCheck
(
Klass
,
'
runJob1
'
,
service1
);
...
@@ -3136,6 +3195,7 @@
...
@@ -3136,6 +3195,7 @@
document
.
getElementById
(
'
qunit-fixture
'
).
innerHTML
=
"
<div></div>
"
;
document
.
getElementById
(
'
qunit-fixture
'
).
innerHTML
=
"
<div></div>
"
;
stop
();
stop
();
expect
(
8
);
renderJS
.
declareGadgetKlass
(
html_url
)
renderJS
.
declareGadgetKlass
(
html_url
)
.
then
(
function
(
Klass
)
{
.
then
(
function
(
Klass
)
{
declareJobToCheck
(
Klass
,
'
runJob1
'
,
service1
);
declareJobToCheck
(
Klass
,
'
runJob1
'
,
service1
);
...
@@ -3199,6 +3259,7 @@
...
@@ -3199,6 +3259,7 @@
document
.
getElementById
(
'
qunit-fixture
'
).
innerHTML
=
"
<div></div>
"
;
document
.
getElementById
(
'
qunit-fixture
'
).
innerHTML
=
"
<div></div>
"
;
stop
();
stop
();
expect
(
8
);
renderJS
.
declareGadgetKlass
(
html_url
)
renderJS
.
declareGadgetKlass
(
html_url
)
.
then
(
function
(
Klass
)
{
.
then
(
function
(
Klass
)
{
declareJobToCheck
(
Klass
,
'
runJob1
'
,
service1
);
declareJobToCheck
(
Klass
,
'
runJob1
'
,
service1
);
...
@@ -3257,6 +3318,7 @@
...
@@ -3257,6 +3318,7 @@
document
.
getElementById
(
'
qunit-fixture
'
).
innerHTML
=
document
.
getElementById
(
'
qunit-fixture
'
).
innerHTML
=
"
<div></div><span></span>
"
;
"
<div></div><span></span>
"
;
stop
();
stop
();
expect
(
4
);
renderJS
.
declareGadgetKlass
(
html_url
)
renderJS
.
declareGadgetKlass
(
html_url
)
.
then
(
function
(
Klass
)
{
.
then
(
function
(
Klass
)
{
declareJobToCheck
(
Klass
,
'
runJob1
'
,
service1
);
declareJobToCheck
(
Klass
,
'
runJob1
'
,
service1
);
...
@@ -3327,6 +3389,7 @@
...
@@ -3327,6 +3389,7 @@
document
.
getElementById
(
'
qunit-fixture
'
).
innerHTML
=
"
<div></div>
"
;
document
.
getElementById
(
'
qunit-fixture
'
).
innerHTML
=
"
<div></div>
"
;
stop
();
stop
();
expect
(
2
);
renderJS
.
declareGadgetKlass
(
html_url
)
renderJS
.
declareGadgetKlass
(
html_url
)
.
then
(
function
(
Klass
)
{
.
then
(
function
(
Klass
)
{
...
@@ -3392,6 +3455,7 @@
...
@@ -3392,6 +3455,7 @@
document
.
getElementById
(
'
qunit-fixture
'
).
innerHTML
=
"
<div></div>
"
;
document
.
getElementById
(
'
qunit-fixture
'
).
innerHTML
=
"
<div></div>
"
;
stop
();
stop
();
expect
(
3
);
renderJS
.
declareGadgetKlass
(
html_url
)
renderJS
.
declareGadgetKlass
(
html_url
)
.
then
(
function
(
Klass
)
{
.
then
(
function
(
Klass
)
{
...
@@ -3551,6 +3615,7 @@
...
@@ -3551,6 +3615,7 @@
},
html
]);
},
html
]);
stop
();
stop
();
expect
(
1
);
gadget
.
declareGadget
(
url
)
//, document.getElementById('qunit-fixture'))
gadget
.
declareGadget
(
url
)
//, document.getElementById('qunit-fixture'))
.
then
(
function
()
{
.
then
(
function
()
{
ok
(
true
);
ok
(
true
);
...
@@ -3579,6 +3644,7 @@
...
@@ -3579,6 +3644,7 @@
},
html
]);
},
html
]);
stop
();
stop
();
expect
(
3
);
gadget
.
declareGadget
(
url
)
//, document.getElementById('qunit-fixture'))
gadget
.
declareGadget
(
url
)
//, document.getElementById('qunit-fixture'))
.
then
(
function
(
new_gadget
)
{
.
then
(
function
(
new_gadget
)
{
equal
(
new_gadget
.
__path
,
url
);
equal
(
new_gadget
.
__path
,
url
);
...
@@ -3606,6 +3672,7 @@
...
@@ -3606,6 +3672,7 @@
},
html
]);
},
html
]);
stop
();
stop
();
expect
(
2
);
gadget
.
declareGadget
(
url
)
//, document.getElementById('qunit-fixture'))
gadget
.
declareGadget
(
url
)
//, document.getElementById('qunit-fixture'))
.
then
(
function
(
new_gadget
)
{
.
then
(
function
(
new_gadget
)
{
ok
(
new_gadget
.
hasOwnProperty
(
"
__sub_gadget_dict
"
));
ok
(
new_gadget
.
hasOwnProperty
(
"
__sub_gadget_dict
"
));
...
@@ -3620,6 +3687,7 @@
...
@@ -3620,6 +3687,7 @@
// Check that missing url reject the declaration
// Check that missing url reject the declaration
var
gadget
=
new
RenderJSGadget
();
var
gadget
=
new
RenderJSGadget
();
stop
();
stop
();
expect
(
1
);
gadget
.
declareGadget
()
gadget
.
declareGadget
()
.
fail
(
function
()
{
.
fail
(
function
()
{
ok
(
true
);
ok
(
true
);
...
@@ -3675,6 +3743,7 @@
...
@@ -3675,6 +3743,7 @@
document
.
getElementById
(
'
qunit-fixture
'
).
innerHTML
=
document
.
getElementById
(
'
qunit-fixture
'
).
innerHTML
=
"
<div></div><div>bar</div>
"
;
"
<div></div><div>bar</div>
"
;
stop
();
stop
();
expect
(
12
);
gadget
.
declareGadget
(
html_url
)
gadget
.
declareGadget
(
html_url
)
.
then
(
function
(
new_gadget
)
{
.
then
(
function
(
new_gadget
)
{
equal
(
document
.
getElementById
(
'
qunit-fixture
'
).
innerHTML
,
equal
(
document
.
getElementById
(
'
qunit-fixture
'
).
innerHTML
,
...
@@ -3751,6 +3820,7 @@
...
@@ -3751,6 +3820,7 @@
},
html
]);
},
html
]);
stop
();
stop
();
expect
(
1
);
gadget
.
declareGadget
(
html_url
)
gadget
.
declareGadget
(
html_url
)
.
then
(
function
(
new_gadget
)
{
.
then
(
function
(
new_gadget
)
{
equal
(
window
.
test_js1
.
test_js2
.
test_js3
.
test_js4
.
test_js5
.
test_js6
,
equal
(
window
.
test_js1
.
test_js2
.
test_js3
.
test_js4
.
test_js5
.
test_js6
,
...
@@ -3775,6 +3845,7 @@
...
@@ -3775,6 +3845,7 @@
},
""
]);
},
""
]);
stop
();
stop
();
expect
(
1
);
gadget
.
declareGadget
(
html_url
)
gadget
.
declareGadget
(
html_url
)
.
then
(
function
(
new_gadget
)
{
.
then
(
function
(
new_gadget
)
{
ok
(
false
);
ok
(
false
);
...
@@ -3804,6 +3875,7 @@
...
@@ -3804,6 +3875,7 @@
});
});
stop
();
stop
();
expect
(
1
);
gadget
.
declareGadget
(
html_url
)
gadget
.
declareGadget
(
html_url
)
.
then
(
function
(
new_gadget
)
{
.
then
(
function
(
new_gadget
)
{
ok
(
false
);
ok
(
false
);
...
@@ -3840,6 +3912,7 @@
...
@@ -3840,6 +3912,7 @@
});
});
stop
();
stop
();
expect
(
2
);
document
.
getElementById
(
'
qunit-fixture
'
).
innerHTML
=
document
.
getElementById
(
'
qunit-fixture
'
).
innerHTML
=
"
<div></div><div></div>
"
;
"
<div></div><div></div>
"
;
gadget
.
declareGadget
(
html_url
)
gadget
.
declareGadget
(
html_url
)
...
@@ -3880,6 +3953,7 @@
...
@@ -3880,6 +3953,7 @@
mock
.
expects
(
"
parseGadgetHTMLDocument
"
).
once
().
returns
({});
mock
.
expects
(
"
parseGadgetHTMLDocument
"
).
once
().
returns
({});
stop
();
stop
();
expect
(
1
);
RSVP
.
all
([
RSVP
.
all
([
gadget
.
declareGadget
(
html_url
),
gadget
.
declareGadget
(
html_url
),
gadget
.
declareGadget
(
html_url
)
gadget
.
declareGadget
(
html_url
)
...
@@ -3914,6 +3988,7 @@
...
@@ -3914,6 +3988,7 @@
mock
.
expects
(
"
parseGadgetHTMLDocument
"
).
once
().
returns
({});
mock
.
expects
(
"
parseGadgetHTMLDocument
"
).
once
().
returns
({});
stop
();
stop
();
expect
(
1
);
gadget
.
declareGadget
(
html_url
)
gadget
.
declareGadget
(
html_url
)
.
then
(
function
()
{
.
then
(
function
()
{
ok
(
false
);
ok
(
false
);
...
@@ -3946,6 +4021,7 @@
...
@@ -3946,6 +4021,7 @@
},
"
<html><body></body></html>
"
]);
},
"
<html><body></body></html>
"
]);
stop
();
stop
();
expect
(
3
);
renderJS
.
declareGadgetKlass
(
html_url
)
renderJS
.
declareGadgetKlass
(
html_url
)
.
then
(
function
(
Klass
)
{
.
then
(
function
(
Klass
)
{
// Create a ready function
// Create a ready function
...
@@ -3987,6 +4063,7 @@
...
@@ -3987,6 +4063,7 @@
},
"
<html><body></body></html>
"
]);
},
"
<html><body></body></html>
"
]);
stop
();
stop
();
expect
(
1
);
renderJS
.
declareGadgetKlass
(
html_url
)
renderJS
.
declareGadgetKlass
(
html_url
)
.
then
(
function
(
Klass
)
{
.
then
(
function
(
Klass
)
{
// Create a ready function
// Create a ready function
...
@@ -4019,6 +4096,7 @@
...
@@ -4019,6 +4096,7 @@
},
"
<html><body></body></html>
"
]);
},
"
<html><body></body></html>
"
]);
stop
();
stop
();
expect
(
5
);
renderJS
.
declareGadgetKlass
(
html_url
)
renderJS
.
declareGadgetKlass
(
html_url
)
.
then
(
function
(
Klass
)
{
.
then
(
function
(
Klass
)
{
return
gadget
.
declareGadget
(
html_url
);
return
gadget
.
declareGadget
(
html_url
);
...
@@ -4056,6 +4134,7 @@
...
@@ -4056,6 +4134,7 @@
},
"
<html><body></body></html>
"
]);
},
"
<html><body></body></html>
"
]);
stop
();
stop
();
expect
(
3
);
renderJS
.
declareGadgetKlass
(
html_url
)
renderJS
.
declareGadgetKlass
(
html_url
)
.
then
(
function
(
Klass
)
{
.
then
(
function
(
Klass
)
{
// Create a ready function
// Create a ready function
...
@@ -4089,6 +4168,7 @@
...
@@ -4089,6 +4168,7 @@
document
.
getElementById
(
'
qunit-fixture
'
).
textContent
=
""
;
document
.
getElementById
(
'
qunit-fixture
'
).
textContent
=
""
;
stop
();
stop
();
expect
(
1
);
renderJS
.
declareGadgetKlass
(
html_url
)
renderJS
.
declareGadgetKlass
(
html_url
)
.
then
(
function
(
Klass
)
{
.
then
(
function
(
Klass
)
{
return
gadget
.
declareGadget
(
return
gadget
.
declareGadget
(
...
@@ -4123,6 +4203,7 @@
...
@@ -4123,6 +4203,7 @@
document
.
getElementById
(
'
qunit-fixture
'
).
textContent
=
""
;
document
.
getElementById
(
'
qunit-fixture
'
).
textContent
=
""
;
stop
();
stop
();
expect
(
3
);
renderJS
.
declareGadgetKlass
(
html_url
)
renderJS
.
declareGadgetKlass
(
html_url
)
.
then
(
function
(
Klass
)
{
.
then
(
function
(
Klass
)
{
return
gadget
.
declareGadget
(
return
gadget
.
declareGadget
(
...
@@ -4159,6 +4240,7 @@
...
@@ -4159,6 +4240,7 @@
document
.
getElementById
(
'
qunit-fixture
'
).
textContent
=
""
;
document
.
getElementById
(
'
qunit-fixture
'
).
textContent
=
""
;
stop
();
stop
();
expect
(
9
);
renderJS
.
declareGadgetKlass
(
html_url
)
renderJS
.
declareGadgetKlass
(
html_url
)
.
then
(
function
(
Klass
)
{
.
then
(
function
(
Klass
)
{
return
gadget
.
declareGadget
(
return
gadget
.
declareGadget
(
...
@@ -4228,6 +4310,7 @@
...
@@ -4228,6 +4310,7 @@
},
"
<html><body></body></html>
"
]);
},
"
<html><body></body></html>
"
]);
stop
();
stop
();
expect
(
5
);
gadget
.
declareGadget
(
html_url
)
gadget
.
declareGadget
(
html_url
)
.
then
(
function
(
new_gadget
)
{
.
then
(
function
(
new_gadget
)
{
return
new_gadget
.
__aq_parent
(
return
new_gadget
.
__aq_parent
(
...
@@ -4271,6 +4354,7 @@
...
@@ -4271,6 +4354,7 @@
},
"
<html><body></body></html>
"
]);
},
"
<html><body></body></html>
"
]);
stop
();
stop
();
expect
(
4
);
gadget
.
declareGadget
(
html_url
,
{
scope
:
"
bar
"
})
gadget
.
declareGadget
(
html_url
,
{
scope
:
"
bar
"
})
.
then
(
function
(
new_gadget
)
{
.
then
(
function
(
new_gadget
)
{
return
new_gadget
.
__aq_parent
(
return
new_gadget
.
__aq_parent
(
...
@@ -4314,6 +4398,7 @@
...
@@ -4314,6 +4398,7 @@
},
"
<html><body></body></html>
"
]);
},
"
<html><body></body></html>
"
]);
stop
();
stop
();
expect
(
4
);
gadget
.
declareGadget
(
html_url
,
{
scope
:
"
bar
"
})
gadget
.
declareGadget
(
html_url
,
{
scope
:
"
bar
"
})
.
then
(
function
(
result
)
{
.
then
(
function
(
result
)
{
new_gadget
=
result
;
new_gadget
=
result
;
...
@@ -4352,6 +4437,7 @@
...
@@ -4352,6 +4437,7 @@
},
"
<html><body></body></html>
"
]);
},
"
<html><body></body></html>
"
]);
stop
();
stop
();
expect
(
2
);
gadget
.
declareGadget
(
html_url
)
gadget
.
declareGadget
(
html_url
)
.
then
(
function
(
new_gadget
)
{
.
then
(
function
(
new_gadget
)
{
return
new_gadget
.
__aq_parent
(
"
foo
"
,
[]);
return
new_gadget
.
__aq_parent
(
"
foo
"
,
[]);
...
@@ -4401,6 +4487,7 @@
...
@@ -4401,6 +4487,7 @@
};
};
stop
();
stop
();
expect
(
8
);
gadget
.
declareGadget
(
html_url
)
gadget
.
declareGadget
(
html_url
)
.
then
(
function
(
new_gadget
)
{
.
then
(
function
(
new_gadget
)
{
return
new_gadget
.
__aq_parent
(
original_method_name
,
return
new_gadget
.
__aq_parent
(
original_method_name
,
...
@@ -4429,6 +4516,7 @@
...
@@ -4429,6 +4516,7 @@
},
"
raw html
"
]);
},
"
raw html
"
]);
stop
();
stop
();
expect
(
1
);
parent_gadget
.
declareGadget
(
gadget_path
)
parent_gadget
.
declareGadget
(
gadget_path
)
.
then
(
function
(
gadget
)
{
.
then
(
function
(
gadget
)
{
equal
(
gadget
.
__path
,
absolute_path
);
equal
(
gadget
.
__path
,
absolute_path
);
...
@@ -4459,6 +4547,7 @@
...
@@ -4459,6 +4547,7 @@
spy
=
sinon
.
spy
(
renderJS
,
"
parseGadgetHTMLDocument
"
);
spy
=
sinon
.
spy
(
renderJS
,
"
parseGadgetHTMLDocument
"
);
stop
();
stop
();
expect
(
9
);
gadget
.
declareGadget
(
html_url
)
gadget
.
declareGadget
(
html_url
)
.
then
(
function
(
g
)
{
.
then
(
function
(
g
)
{
equal
(
spy
.
callCount
,
2
);
equal
(
spy
.
callCount
,
2
);
...
@@ -4511,6 +4600,7 @@
...
@@ -4511,6 +4600,7 @@
spy
=
sinon
.
spy
(
renderJS
,
"
parseGadgetHTMLDocument
"
);
spy
=
sinon
.
spy
(
renderJS
,
"
parseGadgetHTMLDocument
"
);
stop
();
stop
();
expect
(
6
);
gadget
.
declareGadget
(
html_url
)
gadget
.
declareGadget
(
html_url
)
.
then
(
function
(
g
)
{
.
then
(
function
(
g
)
{
equal
(
spy
.
callCount
,
2
);
equal
(
spy
.
callCount
,
2
);
...
@@ -4556,6 +4646,7 @@
...
@@ -4556,6 +4646,7 @@
document
.
getElementById
(
"
qunit-fixture
"
).
textContent
=
""
;
document
.
getElementById
(
"
qunit-fixture
"
).
textContent
=
""
;
stop
();
stop
();
expect
(
3
);
gadget
.
declareGadget
(
html_url
,
{
gadget
.
declareGadget
(
html_url
,
{
element
:
document
.
getElementById
(
'
qunit-fixture
'
)
element
:
document
.
getElementById
(
'
qunit-fixture
'
)
})
})
...
@@ -4597,6 +4688,7 @@
...
@@ -4597,6 +4688,7 @@
},
"
raw html
"
]);
},
"
raw html
"
]);
stop
();
stop
();
expect
(
2
);
gadget
.
declareGadget
(
html_url
)
gadget
.
declareGadget
(
html_url
)
.
then
(
function
()
{
.
then
(
function
()
{
ok
(
false
);
ok
(
false
);
...
@@ -4724,6 +4816,7 @@
...
@@ -4724,6 +4816,7 @@
},
"
<html><body><p>foo</p></body></html>
"
]);
},
"
<html><body><p>foo</p></body></html>
"
]);
stop
();
stop
();
expect
(
2
);
renderJS
.
declareGadgetKlass
(
html_url
)
renderJS
.
declareGadgetKlass
(
html_url
)
.
then
(
function
(
Klass
)
{
.
then
(
function
(
Klass
)
{
return
gadget
.
declareGadget
(
html_url
,
{
sandbox
:
'
iframe
'
});
return
gadget
.
declareGadget
(
html_url
,
{
sandbox
:
'
iframe
'
});
...
@@ -4753,6 +4846,7 @@
...
@@ -4753,6 +4846,7 @@
},
"
<html><body><p>foo</p></body></html>
"
]);
},
"
<html><body><p>foo</p></body></html>
"
]);
stop
();
stop
();
expect
(
2
);
renderJS
.
declareGadgetKlass
(
html_url
)
renderJS
.
declareGadgetKlass
(
html_url
)
.
then
(
function
(
Klass
)
{
.
then
(
function
(
Klass
)
{
return
gadget
.
declareGadget
(
html_url
,
{
return
gadget
.
declareGadget
(
html_url
,
{
...
@@ -4785,6 +4879,7 @@
...
@@ -4785,6 +4879,7 @@
document
.
getElementById
(
"
qunit-fixture
"
).
textContent
=
""
;
document
.
getElementById
(
"
qunit-fixture
"
).
textContent
=
""
;
stop
();
stop
();
expect
(
4
);
gadget
.
declareGadget
(
url
,
{
gadget
.
declareGadget
(
url
,
{
sandbox
:
'
iframe
'
,
sandbox
:
'
iframe
'
,
element
:
document
.
getElementById
(
'
qunit-fixture
'
),
element
:
document
.
getElementById
(
'
qunit-fixture
'
),
...
@@ -4822,6 +4917,7 @@
...
@@ -4822,6 +4917,7 @@
parent_gadget
.
__path
=
parent_path
;
parent_gadget
.
__path
=
parent_path
;
stop
();
stop
();
expect
(
1
);
parent_gadget
.
declareGadget
(
gadget_path
,
{
parent_gadget
.
declareGadget
(
gadget_path
,
{
sandbox
:
'
iframe
'
,
sandbox
:
'
iframe
'
,
element
:
document
.
getElementById
(
'
qunit-fixture
'
)
element
:
document
.
getElementById
(
'
qunit-fixture
'
)
...
@@ -4851,6 +4947,7 @@
...
@@ -4851,6 +4947,7 @@
gadget
.
__sub_gadget_dict
=
{};
gadget
.
__sub_gadget_dict
=
{};
stop
();
stop
();
expect
(
2
);
gadget
.
declareGadget
(
url
,
{
gadget
.
declareGadget
(
url
,
{
sandbox
:
'
iframe
'
,
sandbox
:
'
iframe
'
,
element
:
document
.
getElementById
(
'
qunit-fixture
'
)
element
:
document
.
getElementById
(
'
qunit-fixture
'
)
...
@@ -4888,6 +4985,7 @@
...
@@ -4888,6 +4985,7 @@
gadget
.
__sub_gadget_dict
=
{};
gadget
.
__sub_gadget_dict
=
{};
stop
();
stop
();
expect
(
23
);
gadget
.
declareGadget
(
url
,
{
gadget
.
declareGadget
(
url
,
{
sandbox
:
'
iframe
'
,
sandbox
:
'
iframe
'
,
element
:
document
.
getElementById
(
'
qunit-fixture
'
),
element
:
document
.
getElementById
(
'
qunit-fixture
'
),
...
@@ -5115,6 +5213,7 @@
...
@@ -5115,6 +5213,7 @@
gadget
.
__sub_gadget_dict
=
{};
gadget
.
__sub_gadget_dict
=
{};
stop
();
stop
();
expect
(
16
);
gadget
.
declareGadget
(
url
,
{
gadget
.
declareGadget
(
url
,
{
sandbox
:
'
iframe
'
,
sandbox
:
'
iframe
'
,
element
:
document
.
getElementById
(
'
qunit-fixture
'
)
element
:
document
.
getElementById
(
'
qunit-fixture
'
)
...
@@ -5261,6 +5360,7 @@
...
@@ -5261,6 +5360,7 @@
gadget
.
__sub_gadget_dict
=
{};
gadget
.
__sub_gadget_dict
=
{};
stop
();
stop
();
expect
(
16
);
gadget
.
declareGadget
(
url
,
{
gadget
.
declareGadget
(
url
,
{
sandbox
:
'
iframe
'
,
sandbox
:
'
iframe
'
,
element
:
document
.
getElementById
(
'
qunit-fixture
'
)
element
:
document
.
getElementById
(
'
qunit-fixture
'
)
...
@@ -5389,6 +5489,7 @@
...
@@ -5389,6 +5489,7 @@
url
=
"
./embedded_fail.html
"
;
url
=
"
./embedded_fail.html
"
;
stop
();
stop
();
expect
(
1
);
gadget
.
declareGadget
(
url
,
{
gadget
.
declareGadget
(
url
,
{
sandbox
:
'
iframe
'
,
sandbox
:
'
iframe
'
,
element
:
document
.
getElementById
(
'
qunit-fixture
'
)
element
:
document
.
getElementById
(
'
qunit-fixture
'
)
...
@@ -5410,6 +5511,7 @@
...
@@ -5410,6 +5511,7 @@
url
=
"
./embedded_empty.html
"
;
url
=
"
./embedded_empty.html
"
;
stop
();
stop
();
expect
(
2
);
gadget
.
declareGadget
(
url
,
{
gadget
.
declareGadget
(
url
,
{
sandbox
:
'
iframe
'
,
sandbox
:
'
iframe
'
,
element
:
document
.
getElementById
(
'
qunit-fixture
'
)
element
:
document
.
getElementById
(
'
qunit-fixture
'
)
...
@@ -5432,6 +5534,7 @@
...
@@ -5432,6 +5534,7 @@
url
=
"
./embedded_404.html
"
;
url
=
"
./embedded_404.html
"
;
stop
();
stop
();
expect
(
2
);
gadget
.
declareGadget
(
url
,
{
gadget
.
declareGadget
(
url
,
{
sandbox
:
'
iframe
'
,
sandbox
:
'
iframe
'
,
element
:
document
.
getElementById
(
'
qunit-fixture
'
)
element
:
document
.
getElementById
(
'
qunit-fixture
'
)
...
@@ -5481,6 +5584,7 @@
...
@@ -5481,6 +5584,7 @@
url
=
"
./embedded_non_renderjs.html
"
;
url
=
"
./embedded_non_renderjs.html
"
;
stop
();
stop
();
expect
(
2
);
gadget
.
declareGadget
(
url
,
{
gadget
.
declareGadget
(
url
,
{
sandbox
:
'
iframe
'
,
sandbox
:
'
iframe
'
,
element
:
document
.
getElementById
(
'
qunit-fixture
'
)
element
:
document
.
getElementById
(
'
qunit-fixture
'
)
...
@@ -5542,6 +5646,7 @@
...
@@ -5542,6 +5646,7 @@
parent_gadget
.
__path
=
parent_path
;
parent_gadget
.
__path
=
parent_path
;
stop
();
stop
();
expect
(
3
);
return
new
RSVP
.
Queue
()
return
new
RSVP
.
Queue
()
.
then
(
function
()
{
.
then
(
function
()
{
return
readBlobAsDataURL
(
new
Blob
([
data_url_html
],
return
readBlobAsDataURL
(
new
Blob
([
data_url_html
],
...
@@ -5583,6 +5688,7 @@
...
@@ -5583,6 +5688,7 @@
var
gadget
=
new
RenderJSGadget
();
var
gadget
=
new
RenderJSGadget
();
gadget
.
__sub_gadget_dict
=
{
foo
:
"
bar
"
};
gadget
.
__sub_gadget_dict
=
{
foo
:
"
bar
"
};
stop
();
stop
();
expect
(
1
);
gadget
.
getDeclaredGadget
(
"
foo
"
)
gadget
.
getDeclaredGadget
(
"
foo
"
)
.
then
(
function
(
result
)
{
.
then
(
function
(
result
)
{
equal
(
result
,
"
bar
"
);
equal
(
result
,
"
bar
"
);
...
@@ -5597,6 +5703,7 @@
...
@@ -5597,6 +5703,7 @@
var
gadget
=
new
RenderJSGadget
();
var
gadget
=
new
RenderJSGadget
();
gadget
.
__sub_gadget_dict
=
{};
gadget
.
__sub_gadget_dict
=
{};
stop
();
stop
();
expect
(
2
);
gadget
.
getDeclaredGadget
(
"
foo
"
)
gadget
.
getDeclaredGadget
(
"
foo
"
)
.
then
(
function
()
{
.
then
(
function
()
{
ok
(
false
,
"
getDeclaredGadget should fail
"
);
ok
(
false
,
"
getDeclaredGadget should fail
"
);
...
@@ -5623,6 +5730,7 @@
...
@@ -5623,6 +5730,7 @@
var
gadget
=
new
RenderJSGadget
();
var
gadget
=
new
RenderJSGadget
();
gadget
.
__sub_gadget_dict
=
{
foo
:
"
bar
"
};
gadget
.
__sub_gadget_dict
=
{
foo
:
"
bar
"
};
stop
();
stop
();
expect
(
2
);
gadget
.
dropGadget
(
"
foo
"
)
gadget
.
dropGadget
(
"
foo
"
)
.
then
(
function
(
result
)
{
.
then
(
function
(
result
)
{
equal
(
result
,
undefined
);
equal
(
result
,
undefined
);
...
@@ -5638,6 +5746,7 @@
...
@@ -5638,6 +5746,7 @@
var
gadget
=
new
RenderJSGadget
();
var
gadget
=
new
RenderJSGadget
();
gadget
.
__sub_gadget_dict
=
{};
gadget
.
__sub_gadget_dict
=
{};
stop
();
stop
();
expect
(
2
);
gadget
.
dropGadget
(
"
foo
"
)
gadget
.
dropGadget
(
"
foo
"
)
.
then
(
function
()
{
.
then
(
function
()
{
ok
(
false
,
"
dropGadget should fail
"
);
ok
(
false
,
"
dropGadget should fail
"
);
...
@@ -5681,6 +5790,7 @@
...
@@ -5681,6 +5790,7 @@
}
}
stop
();
stop
();
expect
(
21
);
root_gadget_defer
.
promise
root_gadget_defer
.
promise
.
then
(
function
(
root_gadget_list
)
{
.
then
(
function
(
root_gadget_list
)
{
var
root_gadget
=
root_gadget_list
[
0
],
var
root_gadget
=
root_gadget_list
[
0
],
...
@@ -5763,6 +5873,7 @@
...
@@ -5763,6 +5873,7 @@
test
(
'
__aq_parent fails on the root gadget
'
,
function
()
{
test
(
'
__aq_parent fails on the root gadget
'
,
function
()
{
stop
();
stop
();
expect
(
2
);
root_gadget_defer
.
promise
root_gadget_defer
.
promise
.
then
(
function
(
root_gadget_list
)
{
.
then
(
function
(
root_gadget_list
)
{
return
root_gadget_list
[
0
].
__aq_parent
(
"
foo
"
,
"
bar
"
);
return
root_gadget_list
[
0
].
__aq_parent
(
"
foo
"
,
"
bar
"
);
...
@@ -5781,6 +5892,7 @@
...
@@ -5781,6 +5892,7 @@
fixture
.
innerHTML
=
fixture
.
innerHTML
=
"
<iframe id=renderjsIframe src='./not_declared_gadget.html'></iframe>
"
;
"
<iframe id=renderjsIframe src='./not_declared_gadget.html'></iframe>
"
;
stop
();
stop
();
expect
(
2
);
return
RSVP
.
delay
(
1500
)
return
RSVP
.
delay
(
1500
)
.
then
(
function
()
{
.
then
(
function
()
{
var
iframe
=
document
.
getElementById
(
'
renderjsIframe
'
),
var
iframe
=
document
.
getElementById
(
'
renderjsIframe
'
),
...
@@ -5809,6 +5921,7 @@
...
@@ -5809,6 +5921,7 @@
"
<iframe id=renderjsIframe src='./unload_gadget.html'></iframe>
"
;
"
<iframe id=renderjsIframe src='./unload_gadget.html'></iframe>
"
;
iframe
=
document
.
getElementById
(
'
renderjsIframe
'
);
iframe
=
document
.
getElementById
(
'
renderjsIframe
'
);
stop
();
stop
();
expect
(
1
);
function
waitForPageChanged
()
{
function
waitForPageChanged
()
{
var
iframe_body
=
iframe
.
contentWindow
.
document
.
body
,
var
iframe_body
=
iframe
.
contentWindow
.
document
.
body
,
...
@@ -5870,6 +5983,7 @@
...
@@ -5870,6 +5983,7 @@
"
<iframe id=renderjsIframe src='./error_gadget.html'></iframe>
"
;
"
<iframe id=renderjsIframe src='./error_gadget.html'></iframe>
"
;
iframe
=
document
.
getElementById
(
'
renderjsIframe
'
);
iframe
=
document
.
getElementById
(
'
renderjsIframe
'
);
stop
();
stop
();
expect
(
3
);
return
new
RSVP
.
Promise
(
function
(
resolve
,
reject
)
{
return
new
RSVP
.
Promise
(
function
(
resolve
,
reject
)
{
iframe
.
addEventListener
(
"
load
"
,
function
(
evt
)
{
iframe
.
addEventListener
(
"
load
"
,
function
(
evt
)
{
...
@@ -5903,6 +6017,7 @@
...
@@ -5903,6 +6017,7 @@
"
src='./inject_script.html'></iframe>
"
;
"
src='./inject_script.html'></iframe>
"
;
iframe
=
document
.
getElementById
(
"
renderjsIsolatedIframe
"
);
iframe
=
document
.
getElementById
(
"
renderjsIsolatedIframe
"
);
stop
();
stop
();
expect
(
3
);
return
new
RSVP
.
Promise
(
function
(
resolve
,
reject
)
{
return
new
RSVP
.
Promise
(
function
(
resolve
,
reject
)
{
iframe
.
addEventListener
(
"
load
"
,
function
(
e
)
{
iframe
.
addEventListener
(
"
load
"
,
function
(
e
)
{
...
...
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