summaryrefslogtreecommitdiff
path: root/spec/frontend/lib/utils/common_utils_spec.js
diff options
context:
space:
mode:
Diffstat (limited to 'spec/frontend/lib/utils/common_utils_spec.js')
-rw-r--r--spec/frontend/lib/utils/common_utils_spec.js23
1 files changed, 23 insertions, 0 deletions
diff --git a/spec/frontend/lib/utils/common_utils_spec.js b/spec/frontend/lib/utils/common_utils_spec.js
index f5a74ee7f09..de1be5bc337 100644
--- a/spec/frontend/lib/utils/common_utils_spec.js
+++ b/spec/frontend/lib/utils/common_utils_spec.js
@@ -279,6 +279,14 @@ describe('common_utils', () => {
top: elementTopWithContext,
});
});
+
+ it('passes through behaviour', () => {
+ commonUtils.scrollToElementWithContext(`#${id}`, { behavior: 'smooth' });
+ expect(window.scrollTo).toHaveBeenCalledWith({
+ behavior: 'smooth',
+ top: elementTopWithContext,
+ });
+ });
});
});
@@ -1000,6 +1008,21 @@ describe('common_utils', () => {
});
});
+ describe('scopedLabelKey', () => {
+ it.each`
+ label | expectedLabelKey
+ ${undefined} | ${''}
+ ${''} | ${''}
+ ${'title'} | ${'title'}
+ ${'scoped::value'} | ${'scoped'}
+ ${'scoped::label::value'} | ${'scoped::label'}
+ ${'scoped::label-some::value'} | ${'scoped::label-some'}
+ ${'scoped::label::some::value'} | ${'scoped::label::some'}
+ `('returns "$expectedLabelKey" when label is "$label"', ({ label, expectedLabelKey }) => {
+ expect(commonUtils.scopedLabelKey({ title: label })).toBe(expectedLabelKey);
+ });
+ });
+
describe('getDashPath', () => {
it('returns the path following /-/', () => {
expect(commonUtils.getDashPath('/some/-/url-with-dashes-/')).toEqual('url-with-dashes-/');