Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F4063933
useInstrument.test.js
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
useInstrument.test.js
View Options
const
useInstrument
=
require
(
'../../../modules/ext.checkUser.tempAccounts/useInstrument.js'
);
describe
(
'useInstrument'
,
()
=>
{
it
(
'should record events'
,
()
=>
{
// Mock EventLogging infrastructure
const
submitInteraction
=
jest
.
fn
();
const
newInstrument
=
jest
.
fn
(
()
=>
(
{
submitInteraction
}
)
);
mw
.
eventLog
=
{
newInstrument
};
const
logEvent
=
useInstrument
();
logEvent
(
'session_end'
);
logEvent
(
'session_start'
,
{
sessionLength
:
3600
}
);
expect
(
newInstrument
).
toHaveBeenCalledTimes
(
1
);
expect
(
submitInteraction
).
toHaveBeenCalledTimes
(
2
);
expect
(
submitInteraction
).
toHaveBeenNthCalledWith
(
1
,
'session_end'
,
{}
);
expect
(
submitInteraction
).
toHaveBeenNthCalledWith
(
2
,
'session_start'
,
{
// eslint-disable-next-line camelcase
action_context
:
JSON
.
stringify
(
{
session_length
:
3600
}
)
}
);
}
);
it
(
'should not try to record events if EventLogging is unavailable'
,
()
=>
{
// Simulate EventLogging being unavailable
mw
.
eventLog
=
undefined
;
const
logEvent
=
useInstrument
();
expect
(
()
=>
{
logEvent
(
'session_end'
);
}
).
not
.
toThrow
();
}
);
}
);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Aug 16 2026, 13:18 (11 w, 6 d ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
d9/db/97ebeee62121c5ad9cb2a0301312
Default Alt Text
useInstrument.test.js (1 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment