Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-09-03 12:08:20 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-09-03 12:08:20 +0300
commita1aeaba23e388ac96d34c135c6c55e414f823487 (patch)
tree12ac28cdba58353efe18053028d6028a965c6358 /spec/frontend/deprecated_jquery_dropdown_spec.js
parentd72fedf168dafcb38bd51b67f86804738000fb48 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/deprecated_jquery_dropdown_spec.js')
-rw-r--r--spec/frontend/deprecated_jquery_dropdown_spec.js36
1 files changed, 36 insertions, 0 deletions
diff --git a/spec/frontend/deprecated_jquery_dropdown_spec.js b/spec/frontend/deprecated_jquery_dropdown_spec.js
index 077657cfee4..e6323859899 100644
--- a/spec/frontend/deprecated_jquery_dropdown_spec.js
+++ b/spec/frontend/deprecated_jquery_dropdown_spec.js
@@ -313,6 +313,42 @@ describe('deprecatedJQueryDropdown', () => {
expect(li.childNodes.length).toEqual(1);
expect(li.textContent).toEqual(text);
});
+
+ describe('with a trackSuggestionsClickedLabel', () => {
+ it('it includes data-track attributes', () => {
+ const dropdown = dropdownWithOptions({
+ trackSuggestionClickedLabel: 'some_value_for_label',
+ });
+ const item = {
+ id: 'some-element-id',
+ text: 'the link text',
+ url: 'http://example.com',
+ category: 'Suggestion category',
+ };
+ const li = dropdown.renderItem(item, null, 3);
+ const link = li.querySelector('a');
+
+ expect(link).toHaveAttr('data-track-event', 'click_text');
+ expect(link).toHaveAttr('data-track-label', 'some_value_for_label');
+ expect(link).toHaveAttr('data-track-value', '3');
+ expect(link).toHaveAttr('data-track-property', 'suggestion-category');
+ });
+
+ it('it defaults property to no_category when category not provided', () => {
+ const dropdown = dropdownWithOptions({
+ trackSuggestionClickedLabel: 'some_value_for_label',
+ });
+ const item = {
+ id: 'some-element-id',
+ text: 'the link text',
+ url: 'http://example.com',
+ };
+ const li = dropdown.renderItem(item);
+ const link = li.querySelector('a');
+
+ expect(link).toHaveAttr('data-track-property', 'no-category');
+ });
+ });
});
it('should keep selected item after selecting a second time', () => {