Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
820bbb95
Commit
820bbb95
authored
Mar 23, 2022
by
Paul Gascou-Vaillancourt
Committed by
Paul Gascou-Vaillancourt
Mar 25, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add unit tests for initArkoseLabsScript
parent
fb5c5f84
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
41 additions
and
0 deletions
+41
-0
ee/spec/frontend/arkose_labs/init_arkose_labs_script_spec.js
ee/spec/frontend/arkose_labs/init_arkose_labs_script_spec.js
+41
-0
No files found.
ee/spec/frontend/arkose_labs/init_arkose_labs_script_spec.js
0 → 100644
View file @
820bbb95
import
{
initArkoseLabsScript
}
from
'
ee/arkose_labs/init_arkose_labs_script
'
;
jest
.
mock
(
'
lodash/uniqueId
'
,
()
=>
()
=>
'
initArkoseLabsScript_callback
'
);
describe
(
'
initArkoseLabsScript
'
,
()
=>
{
let
subject
;
const
initSubject
=
()
=>
{
subject
=
initArkoseLabsScript
({
publicKey
:
'
arkose-labs-public-api-key
'
});
};
const
findScriptTags
=
()
=>
document
.
querySelectorAll
(
'
script
'
);
afterEach
(()
=>
{
subject
=
null
;
document
.
getElementsByTagName
(
'
html
'
)[
0
].
innerHTML
=
''
;
});
it
(
'
sets a global enforcement callback
'
,
()
=>
{
initSubject
();
expect
(
window
.
initArkoseLabsScript_callback
).
not
.
toBe
(
undefined
);
});
it
(
'
adds ArkoseLabs scripts to the HTML head
'
,
()
=>
{
expect
(
findScriptTags
()).
toHaveLength
(
0
);
initSubject
();
expect
(
findScriptTags
()).
toHaveLength
(
1
);
});
it
(
'
when callback is called, cleans up the global object and resolves the Promise
'
,
()
=>
{
initSubject
();
const
enforcement
=
'
ArkoseLabsEnforcement
'
;
window
.
initArkoseLabsScript_callback
(
enforcement
);
expect
(
window
.
initArkoseLabsScript_callback
).
toBe
(
undefined
);
return
expect
(
subject
).
resolves
.
toBe
(
enforcement
);
});
});
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