Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
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
edx
edx-platform
Commits
c5cd67a6
Commit
c5cd67a6
authored
Dec 05, 2012
by
valera-rozuvan
Committed by
Valera Rozuvan
Jan 03, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Work on RequireJS Jasmine test.
parent
f2cce07b
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
39 additions
and
56 deletions
+39
-56
lms/static/coffee/spec/requirejs_spec.coffee
+39
-56
No files found.
lms/static/coffee/spec/requirejs_spec.coffee
View file @
c5cd67a6
describe
(
'RequireJS namespacing'
,
function
()
{
beforeEach
(
function
()
{
this
.
addMatchers
({
requirejsTobeUndefined
:
function
()
{
return
(
typeof
requirejs
===
'undefined'
);
},
requireTobeUndefined
:
function
()
{
return
(
typeof
require
===
'undefined'
);
},
defineTobeUndefined
:
function
()
{
return
(
typeof
define
===
'undefined'
);
},
});
});
describe
"RequireJS namespacing"
,
->
beforeEach
->
@
addMatchers
requirejsTobeUndefined
:
->
typeof
requirejs
is
"undefined"
it
(
'check that the RequireJS object is present in the global namespace'
,
function
()
{
expect
(
RequireJS
).
toEqual
(
jasmine
.
any
(
Object
));
expect
(
window
.
RequireJS
).
toEqual
(
jasmine
.
any
(
Object
));
});
requireTobeUndefined
:
->
typeof
require
is
"undefined"
it
(
'check that requirejs(), require(), and define() are not in the global namespace'
,
function
()
{
expect
({}).
requirejsTobeUndefined
();
expect
({}).
requireTobeUndefined
();
expect
({}).
defineTobeUndefined
();
defineTobeUndefined
:
->
typeof
define
is
"undefined"
expect
(
window
.
requirejs
).
not
.
toBeDefined
();
expect
(
window
.
require
).
not
.
toBeDefined
();
expect
(
window
.
define
).
not
.
toBeDefined
();
});
});
describe
(
'RequireJS module creation'
,
function
()
{
var
inDefineCallback
,
inRequireCallback
;
it
"check that the RequireJS object is present in the global namespace"
,
->
expect
(
RequireJS
).
toEqual
jasmine
.
any
(
Object
)
expect
(
window
.
RequireJS
).
toEqual
jasmine
.
any
(
Object
)
it
(
'check that we can use RequireJS define() and require() a module'
,
function
()
{
runs
(
function
()
{
inDefineCallback
=
false
;
inRequireCallback
=
false
;
it
"check that requirejs(), require(), and define() are not in the global namespace"
,
->
expect
({}).
requirejsTobeUndefined
()
expect
({}).
requireTobeUndefined
()
expect
({}).
defineTobeUndefined
()
expect
(
window
.
requirejs
).
not
.
toBeDefined
()
expect
(
window
.
require
).
not
.
toBeDefined
()
expect
(
window
.
define
).
not
.
toBeDefined
()
RequireJS
.
define
(
'test_module'
,
[],
function
()
{
inDefineCallback
=
true
;
return
{
'module_status'
:
'OK'
};
});
describe
"RequireJS module creation"
,
->
inDefineCallback
=
undefined
inRequireCallback
=
undefined
it
"check that we can use RequireJS define() and require() a module"
,
->
runs
->
inDefineCallback
=
false
inRequireCallback
=
false
RequireJS
.
define
"test_module"
,
[],
->
inDefineCallback
=
true
module_status
:
"OK"
RequireJS
.
require
([
'test_module'
],
function
(
test_module
)
{
inRequireCallback
=
true
;
RequireJS
.
require
[
"test_module"
],
(
test_module
)
->
inRequireCallback
=
true
expect
(
test_module
.
module_status
).
toBe
"OK"
expect
(
test_module
.
module_status
).
toBe
(
'OK'
);
});
});
waitsFor
(
function
()
{
if
((
inDefineCallback
!==
true
)
||
(
inRequireCallback
!==
true
))
{
return
false
;
}
waitsFor
(
->
return
false
if
(
inDefineCallback
isnt
true
)
or
(
inRequireCallback
isnt
true
)
true
),
"We should eventually end up in the defined callback"
,
1000
runs
->
expect
(
inDefineCallback
).
toBeTruthy
()
expect
(
inRequireCallback
).
toBeTruthy
()
return
true
},
'We should eventually end up in the defined callback'
,
1000
);
runs
(
function
()
{
expect
(
inDefineCallback
).
toBeTruthy
();
expect
(
inRequireCallback
).
toBeTruthy
();
});
});
});
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