Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F4058754
container.test.js
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
container.test.js
View Options
import
createContainer
from
'../../src/container'
;
QUnit
.
module
(
'container'
,
{
beforeEach
()
{
this
.
container
=
createContainer
();
this
.
factory
=
this
.
sandbox
.
stub
();
}
}
);
QUnit
.
test
(
'#has'
,
function
(
assert
)
{
this
.
container
.
set
(
'foo'
,
this
.
factory
);
assert
.
true
(
this
.
container
.
has
(
'foo'
),
'The container checks the factory.'
);
}
);
QUnit
.
test
(
'#get'
,
function
(
assert
)
{
const
service
=
{};
this
.
factory
.
returns
(
service
);
this
.
container
.
set
(
'foo'
,
this
.
factory
);
assert
.
strictEqual
(
service
,
this
.
container
.
get
(
'foo'
)
);
assert
.
strictEqual
(
this
.
container
,
this
.
factory
.
getCall
(
0
).
args
[
0
],
'The container uses the factory.'
);
// ---
this
.
container
.
get
(
'foo'
);
assert
.
true
(
this
.
factory
.
calledOnce
,
'It should memoize the result of the factory.'
);
// ---
assert
.
throws
(
()
=>
{
this
.
container
.
get
(
'bar'
);
},
/The service "bar" hasn't been defined./
,
'The container throws an error when no factory exists.'
);
}
);
QUnit
.
test
(
'#get should handle values, not just functions'
,
function
(
assert
)
{
this
.
container
.
set
(
'foo'
,
'bar'
);
assert
.
strictEqual
(
this
.
container
.
get
(
'foo'
),
'bar'
,
'The container understands string values.'
);
}
);
File Metadata
Details
Attached
Mime Type
text/x-java
Expires
Aug 16 2026, 04:58 (12 w, 22 h ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
86/c2/8c6acfc5c1360f496f1681e19bd3
Default Alt Text
container.test.js (1 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment