summaryrefslogtreecommitdiffstats
path: root/src/pybind/mgr/dashboard/frontend/src/app/shared/forms/cd-form.spec.ts
blob: 445c31faf1d198ce4311887b3df162000479c404 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import { CdForm, LoadingStatus } from './cd-form';

describe('CdForm', () => {
  let form: CdForm;

  beforeEach(() => {
    form = new CdForm();
  });

  describe('loading', () => {
    it('should start in loading state', () => {
      expect(form.loading).toBe(LoadingStatus.Loading);
    });

    it('should change to ready when calling loadingReady', () => {
      form.loadingReady();
      expect(form.loading).toBe(LoadingStatus.Ready);
    });

    it('should change to error state calling loadingError', () => {
      form.loadingError();
      expect(form.loading).toBe(LoadingStatus.Error);
    });

    it('should change to loading state calling loadingStart', () => {
      form.loadingError();
      expect(form.loading).toBe(LoadingStatus.Error);
      form.loadingStart();
      expect(form.loading).toBe(LoadingStatus.Loading);
    });
  });
});