diff options
author | Filipa Lacerda <filipa@gitlab.com> | 2017-10-04 16:43:45 +0100 |
---|---|---|
committer | Filipa Lacerda <filipa@gitlab.com> | 2017-10-04 16:45:02 +0100 |
commit | 2e53056e94e2be32d481e084b68be87dc0e448dd (patch) | |
tree | 4b31fcc8f99060555c91479897406445ffcfe45f /spec/javascripts/clusters_spec.js | |
parent | 8d9d0f9401269a5718da9d22a1863a4c4ab5f36e (diff) | |
download | gitlab-ce-2e53056e94e2be32d481e084b68be87dc0e448dd.tar.gz |
Adds Frontend specs
Diffstat (limited to 'spec/javascripts/clusters_spec.js')
-rw-r--r-- | spec/javascripts/clusters_spec.js | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/spec/javascripts/clusters_spec.js b/spec/javascripts/clusters_spec.js new file mode 100644 index 00000000000..2ceb0cfdf4c --- /dev/null +++ b/spec/javascripts/clusters_spec.js @@ -0,0 +1,79 @@ +import Clusters from '~/clusters'; + +describe('Clusters', () => { + let cluster; + preloadFixtures('clusters/show_cluster.html.raw'); + + beforeEach(() => { + loadFixtures('clusters/show_cluster.html.raw'); + cluster = new Clusters(); + }); + + describe('toggle', () => { + it('should update the button and the input field on click', () => { + cluster.toggleButton.click(); + + expect( + cluster.toggleButton.classList, + ).not.toContain('checked'); + + expect( + cluster.toggleInput.getAttribute('value'), + ).toEqual('false'); + }); + }); + + describe('updateContainer', () => { + describe('when creating cluster', () => { + it('should show the creating container', () => { + cluster.updateContainer('creating'); + + expect( + cluster.creatingContainer.classList, + ).not.toContain('hidden'); + expect( + cluster.successContainer.classList, + ).toContain('hidden'); + expect( + cluster.errorContainer.classList, + ).toContain('hidden'); + }); + }); + + describe('when cluster is created', () => { + it('should show the success container', () => { + cluster.updateContainer('created'); + + expect( + cluster.creatingContainer.classList, + ).toContain('hidden'); + expect( + cluster.successContainer.classList, + ).not.toContain('hidden'); + expect( + cluster.errorContainer.classList, + ).toContain('hidden'); + }); + }); + + describe('when cluster has error', () => { + it('should show the error container', () => { + cluster.updateContainer('errored', 'this is an error'); + + expect( + cluster.creatingContainer.classList, + ).toContain('hidden'); + expect( + cluster.successContainer.classList, + ).toContain('hidden'); + expect( + cluster.errorContainer.classList, + ).not.toContain('hidden'); + + expect( + cluster.errorContainer.querySelector('.js-error-reason').textContent, + ).toContain('this is an error'); + }); + }); + }); +}); |