summaryrefslogtreecommitdiffstats
path: root/src/pybind/mgr/dashboard/frontend/src/app/shared/classes/table-status-view-cache.spec.ts
blob: cff2ec33a02bd2f59ec3eb7815d7101e785e7310 (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
33
34
35
36
37
38
39
40
import { ViewCacheStatus } from '../enum/view-cache-status.enum';
import { TableStatusViewCache } from './table-status-view-cache';

describe('TableStatusViewCache', () => {
  it('should create an instance', () => {
    const ts = new TableStatusViewCache();
    expect(ts).toBeTruthy();
    expect(ts).toEqual({ msg: '', type: 'light' });
  });

  it('should create a ValueStale instance', () => {
    let ts = new TableStatusViewCache(ViewCacheStatus.ValueStale);
    expect(ts).toEqual({ type: 'warning', msg: 'Displaying previously cached data.' });

    ts = new TableStatusViewCache(ViewCacheStatus.ValueStale, 'foo bar');
    expect(ts).toEqual({ type: 'warning', msg: 'Displaying previously cached data for foo bar.' });
  });

  it('should create a ValueNone instance', () => {
    let ts = new TableStatusViewCache(ViewCacheStatus.ValueNone);
    expect(ts).toEqual({ type: 'info', msg: 'Retrieving data. Please wait...' });

    ts = new TableStatusViewCache(ViewCacheStatus.ValueNone, 'foo bar');
    expect(ts).toEqual({ type: 'info', msg: 'Retrieving data for foo bar. Please wait...' });
  });

  it('should create a ValueException instance', () => {
    let ts = new TableStatusViewCache(ViewCacheStatus.ValueException);
    expect(ts).toEqual({
      type: 'danger',
      msg: 'Could not load data. Please check the cluster health.'
    });

    ts = new TableStatusViewCache(ViewCacheStatus.ValueException, 'foo bar');
    expect(ts).toEqual({
      type: 'danger',
      msg: 'Could not load data for foo bar. Please check the cluster health.'
    });
  });
});