diff options
author | Kushal Pandya <kushal@gitlab.com> | 2018-02-28 18:03:46 +0530 |
---|---|---|
committer | Kushal Pandya <kushal@gitlab.com> | 2018-02-28 18:03:46 +0530 |
commit | 90baab96e0c3a788e68a48a1adff7954cd88c263 (patch) | |
tree | 9e53e2013d2463c59f1c26626fa700d5d62495e9 | |
parent | f0197d733818c17ad28a92c6f4def6221050f2e0 (diff) | |
download | gitlab-ce-90baab96e0c3a788e68a48a1adff7954cd88c263.tar.gz |
Labels Select Tests43643-fix-mr-label-filtering
-rw-r--r-- | spec/javascripts/labels_select_spec.js | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/spec/javascripts/labels_select_spec.js b/spec/javascripts/labels_select_spec.js new file mode 100644 index 00000000000..b8f7b1dc855 --- /dev/null +++ b/spec/javascripts/labels_select_spec.js @@ -0,0 +1,43 @@ +import LabelsSelect from '~/labels_select'; + +const mockUrl = '/foo/bar/url'; + +const mockLabels = [ + { + id: 26, + title: 'Foo Label', + description: 'Foobar', + color: '#BADA55', + text_color: '#FFFFFF', + }, +]; + +describe('LabelsSelect', () => { + describe('getLabelTemplate', () => { + const label = mockLabels[0]; + let $labelEl; + + beforeEach(() => { + $labelEl = $(LabelsSelect.getLabelTemplate({ + labels: mockLabels, + issueUpdateURL: mockUrl, + })); + }); + + it('generated label item template has correct label URL', () => { + expect($labelEl.attr('href')).toBe('/foo/bar?label_name[]=Foo%20Label'); + }); + + it('generated label item template has correct label title', () => { + expect($labelEl.find('span.label').text()).toBe(label.title); + }); + + it('generated label item template has label description as title attribute', () => { + expect($labelEl.find('span.label').attr('title')).toBe(label.description); + }); + + it('generated label item template has correct label styles', () => { + expect($labelEl.find('span.label').attr('style')).toBe(`background-color: ${label.color}; color: ${label.text_color};`); + }); + }); +}); |