summaryrefslogtreecommitdiff
path: root/spec/frontend/clusters/clusters_bundle_spec.js
diff options
context:
space:
mode:
Diffstat (limited to 'spec/frontend/clusters/clusters_bundle_spec.js')
-rw-r--r--spec/frontend/clusters/clusters_bundle_spec.js34
1 files changed, 32 insertions, 2 deletions
diff --git a/spec/frontend/clusters/clusters_bundle_spec.js b/spec/frontend/clusters/clusters_bundle_spec.js
index 80816faa5fc..517d8781600 100644
--- a/spec/frontend/clusters/clusters_bundle_spec.js
+++ b/spec/frontend/clusters/clusters_bundle_spec.js
@@ -11,6 +11,8 @@ import { loadHTMLFixture } from 'helpers/fixtures';
import { setTestTimeout } from 'helpers/timeout';
import $ from 'jquery';
+jest.mock('~/lib/utils/poll');
+
const { INSTALLING, INSTALLABLE, INSTALLED, UNINSTALLING } = APPLICATION_STATUS;
describe('Clusters', () => {
@@ -44,6 +46,17 @@ describe('Clusters', () => {
mock.restore();
});
+ describe('class constructor', () => {
+ beforeEach(() => {
+ jest.spyOn(Clusters.prototype, 'initPolling');
+ cluster = new Clusters();
+ });
+
+ it('should call initPolling on construct', () => {
+ expect(cluster.initPolling).toHaveBeenCalled();
+ });
+ });
+
describe('toggle', () => {
it('should update the button and the input field on click', done => {
const toggleButton = document.querySelector(
@@ -327,14 +340,31 @@ describe('Clusters', () => {
});
});
- describe('handleSuccess', () => {
+ describe('fetch cluster environments success', () => {
+ beforeEach(() => {
+ jest.spyOn(cluster.store, 'toggleFetchEnvironments').mockReturnThis();
+ jest.spyOn(cluster.store, 'updateEnvironments').mockReturnThis();
+
+ cluster.handleClusterEnvironmentsSuccess({ data: {} });
+ });
+
+ it('toggles the cluster environments loading icon', () => {
+ expect(cluster.store.toggleFetchEnvironments).toHaveBeenCalled();
+ });
+
+ it('updates the store when cluster environments is retrieved', () => {
+ expect(cluster.store.updateEnvironments).toHaveBeenCalled();
+ });
+ });
+
+ describe('handleClusterStatusSuccess', () => {
beforeEach(() => {
jest.spyOn(cluster.store, 'updateStateFromServer').mockReturnThis();
jest.spyOn(cluster, 'toggleIngressDomainHelpText').mockReturnThis();
jest.spyOn(cluster, 'checkForNewInstalls').mockReturnThis();
jest.spyOn(cluster, 'updateContainer').mockReturnThis();
- cluster.handleSuccess({ data: {} });
+ cluster.handleClusterStatusSuccess({ data: {} });
});
it('updates clusters store', () => {