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

model_version_row_spec.js « components « model_registry « ml « frontend « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 9f709f2e07259ff49367f9e695e73a261c75fff1 (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
import { GlLink, GlSprintf, GlTruncate } from '@gitlab/ui';
import { shallowMount } from '@vue/test-utils';
import ListItem from '~/vue_shared/components/registry/list_item.vue';
import TimeAgoTooltip from '~/vue_shared/components/time_ago_tooltip.vue';
import ModelVersionRow from '~/ml/model_registry/components/model_version_row.vue';
import { graphqlModelVersions } from '../graphql_mock_data';

let wrapper;
const createWrapper = (modelVersion = graphqlModelVersions[0]) => {
  wrapper = shallowMount(ModelVersionRow, {
    propsData: { modelVersion },
    stubs: {
      GlSprintf,
      GlTruncate,
    },
  });
};

const findListItem = () => wrapper.findComponent(ListItem);
const findLink = () => findListItem().findComponent(GlLink);
const findTruncated = () => findLink().findComponent(GlTruncate);
const findTooltip = () => findListItem().findComponent(TimeAgoTooltip);

describe('ModelVersionRow', () => {
  beforeEach(() => {
    createWrapper();
  });

  it('Has a link to the model version', () => {
    expect(findTruncated().props('text')).toBe(graphqlModelVersions[0].version);
    expect(findLink().attributes('href')).toBe(graphqlModelVersions[0]._links.showPath);
  });

  it('Shows created at', () => {
    expect(findTooltip().props('time')).toBe(graphqlModelVersions[0].createdAt);
  });
});