Welcome to mirror list, hosted at ThFree Co, Russian Federation.

storage_usage_statistics_spec.js « components « storage « usage_quotas « frontend « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: bb96a12aaf2173b350e65e2a88718b2c0a2ed1a0 (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
41
42
43
44
import { shallowMountExtended } from 'helpers/vue_test_utils_helper';
import StorageUsageStatistics from '~/usage_quotas/storage/components/storage_usage_statistics.vue';
import StorageUsageOverviewCard from '~/usage_quotas/storage/components/storage_usage_overview_card.vue';
import { mockGetNamespaceStorageGraphQLResponse } from '../mock_data';

const defaultProps = {
  usedStorage:
    mockGetNamespaceStorageGraphQLResponse.data.namespace.rootStorageStatistics.storageSize,
  loading: false,
};

describe('StorageUsageStatistics', () => {
  /** @type {import('helpers/vue_test_utils_helper').ExtendedWrapper} */
  let wrapper;

  const createComponent = ({ props = {} } = {}) => {
    wrapper = shallowMountExtended(StorageUsageStatistics, {
      propsData: {
        ...defaultProps,
        ...props,
      },
    });
  };

  const findOverviewSubtitle = () => wrapper.findByTestId('overview-subtitle');
  const findStorageUsageOverviewCard = () => wrapper.findComponent(StorageUsageOverviewCard);

  beforeEach(() => {
    createComponent();
  });

  it('shows the namespace storage overview subtitle', () => {
    expect(findOverviewSubtitle().text()).toBe('Namespace overview');
  });

  describe('StorageStatisticsCard', () => {
    it('passes the correct props to StorageUsageOverviewCard', () => {
      expect(findStorageUsageOverviewCard().props()).toEqual({
        usedStorage: defaultProps.usedStorage,
        loading: false,
      });
    });
  });
});