debian-mirror-gitlab/spec/frontend/ide/components/commit_sidebar/list_spec.js

53 lines
1.2 KiB
JavaScript
Raw Normal View History

2018-05-09 12:01:36 +05:30
import Vue from 'vue';
2020-04-22 19:07:51 +05:30
import { createComponentWithStore } from 'helpers/vue_mount_component_helper';
2018-05-09 12:01:36 +05:30
import commitSidebarList from '~/ide/components/commit_sidebar/list.vue';
2021-03-11 19:13:27 +05:30
import { createStore } from '~/ide/stores';
2020-10-24 23:57:45 +05:30
import { file } from '../../helpers';
2018-05-09 12:01:36 +05:30
describe('Multi-file editor commit sidebar list', () => {
2020-10-24 23:57:45 +05:30
let store;
2018-05-09 12:01:36 +05:30
let vm;
beforeEach(() => {
2020-10-24 23:57:45 +05:30
store = createStore();
2018-05-09 12:01:36 +05:30
const Component = Vue.extend(commitSidebarList);
vm = createComponentWithStore(Component, store, {
title: 'Staged',
fileList: [],
2018-10-15 14:42:47 +05:30
action: 'stageAllChanges',
actionBtnText: 'stage all',
2018-11-08 19:23:39 +05:30
actionBtnIcon: 'history',
activeFileKey: 'staged-testing',
keyPrefix: 'staged',
2018-05-09 12:01:36 +05:30
});
vm.$mount();
});
afterEach(() => {
vm.$destroy();
});
describe('with a list of files', () => {
2021-03-08 18:12:59 +05:30
beforeEach((done) => {
2018-05-09 12:01:36 +05:30
const f = file('file name');
f.changed = true;
vm.fileList.push(f);
Vue.nextTick(done);
});
it('renders list', () => {
2018-11-08 19:23:39 +05:30
expect(vm.$el.querySelectorAll('.multi-file-commit-list > li').length).toBe(1);
2018-05-09 12:01:36 +05:30
});
});
2018-10-15 14:42:47 +05:30
describe('empty files array', () => {
it('renders no changes text when empty', () => {
expect(vm.$el.textContent).toContain('No changes');
2018-05-09 12:01:36 +05:30
});
});
});