summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorClement Ho <ClemMakesApps@gmail.com>2018-05-22 10:45:24 -0500
committerClement Ho <ClemMakesApps@gmail.com>2018-05-22 10:45:24 -0500
commit17f98cf558120a424d8c87c99a42593964e23bde (patch)
tree36b4474ae06587520fa62416bc1f1886c23a17ad /spec
parentb4849eb9ec26e2b8b079213fc3d4264e71284e41 (diff)
downloadgitlab-ce-17f98cf558120a424d8c87c99a42593964e23bde.tar.gz
Remove code from bad merge
Diffstat (limited to 'spec')
-rw-r--r--spec/javascripts/visibility_select_spec.js98
1 files changed, 0 insertions, 98 deletions
diff --git a/spec/javascripts/visibility_select_spec.js b/spec/javascripts/visibility_select_spec.js
deleted file mode 100644
index e75ea745df8..00000000000
--- a/spec/javascripts/visibility_select_spec.js
+++ /dev/null
@@ -1,98 +0,0 @@
-import VisibilitySelect from '~/visibility_select';
-
-(() => {
- describe('VisibilitySelect', function () {
- const lockedElement = document.createElement('div');
- lockedElement.dataset.helpBlock = 'lockedHelpBlock';
-
- const checkedElement = document.createElement('div');
- checkedElement.dataset.description = 'checkedDescription';
-
- const mockElements = {
- container: document.createElement('div'),
- select: document.createElement('div'),
- '.form-text.text-muted': document.createElement('div'),
- '.js-locked': lockedElement,
- 'option:checked': checkedElement,
- };
-
- beforeEach(function () {
- spyOn(Element.prototype, 'querySelector').and.callFake(selector => mockElements[selector]);
- });
-
- describe('constructor', function () {
- beforeEach(function () {
- this.visibilitySelect = new VisibilitySelect(mockElements.container);
- });
-
- it('sets the container member', function () {
- expect(this.visibilitySelect.container).toEqual(mockElements.container);
- });
-
- it('queries and sets the helpBlock member', function () {
- expect(Element.prototype.querySelector).toHaveBeenCalledWith('.form-text.text-muted');
- expect(this.visibilitySelect.helpBlock).toEqual(mockElements['.form-text.text-muted']);
- });
-
- it('queries and sets the select member', function () {
- expect(Element.prototype.querySelector).toHaveBeenCalledWith('select');
- expect(this.visibilitySelect.select).toEqual(mockElements.select);
- });
-
- describe('if there is no container element provided', function () {
- it('throws an error', function () {
- expect(() => new VisibilitySelect()).toThrowError('VisibilitySelect requires a container element as argument 1');
- });
- });
- });
-
- describe('init', function () {
- describe('if there is a select', function () {
- beforeEach(function () {
- this.visibilitySelect = new VisibilitySelect(mockElements.container);
- });
-
- it('calls updateHelpText', function () {
- spyOn(VisibilitySelect.prototype, 'updateHelpText');
- this.visibilitySelect.init();
- expect(this.visibilitySelect.updateHelpText).toHaveBeenCalled();
- });
-
- it('adds a change event listener', function () {
- spyOn(this.visibilitySelect.select, 'addEventListener');
- this.visibilitySelect.init();
- expect(this.visibilitySelect.select.addEventListener.calls.argsFor(0)).toContain('change');
- });
- });
-
- describe('if there is no select', function () {
- beforeEach(function () {
- mockElements.select = undefined;
- this.visibilitySelect = new VisibilitySelect(mockElements.container);
- this.visibilitySelect.init();
- });
-
- it('updates the helpBlock text to the locked `data-help-block` messaged', function () {
- expect(this.visibilitySelect.helpBlock.textContent)
- .toEqual(lockedElement.dataset.helpBlock);
- });
-
- afterEach(function () {
- mockElements.select = document.createElement('div');
- });
- });
- });
-
- describe('updateHelpText', function () {
- beforeEach(function () {
- this.visibilitySelect = new VisibilitySelect(mockElements.container);
- this.visibilitySelect.init();
- });
-
- it('updates the helpBlock text to the selected options `data-description`', function () {
- expect(this.visibilitySelect.helpBlock.textContent)
- .toEqual(checkedElement.dataset.description);
- });
- });
- });
-})();