debian-mirror-gitlab/spec/javascripts/diffs/components/app_spec.js

56 lines
1.4 KiB
JavaScript
Raw Normal View History

2018-12-05 23:21:45 +05:30
import Vue from 'vue';
import { mountComponentWithStore } from 'spec/helpers/vue_mount_component_helper';
import { TEST_HOST } from 'spec/test_constants';
import App from '~/diffs/components/app.vue';
import createDiffsStore from '../create_diffs_store';
describe('diffs/components/app', () => {
const oldMrTabs = window.mrTabs;
const Component = Vue.extend(App);
let vm;
beforeEach(() => {
// setup globals (needed for component to mount :/)
window.mrTabs = jasmine.createSpyObj('mrTabs', ['resetViewContainer']);
2018-12-23 12:14:25 +05:30
window.mrTabs.expandViewContainer = jasmine.createSpy();
window.location.hash = 'ABC_123';
2018-12-05 23:21:45 +05:30
// setup component
const store = createDiffsStore();
store.state.diffs.isLoading = false;
vm = mountComponentWithStore(Component, {
store,
props: {
endpoint: `${TEST_HOST}/diff/endpoint`,
projectPath: 'namespace/project',
currentUser: {},
},
});
});
afterEach(() => {
// reset globals
window.mrTabs = oldMrTabs;
// reset component
vm.$destroy();
});
it('does not show commit info', () => {
expect(vm.$el).not.toContainElement('.blob-commit-info');
});
2018-12-23 12:14:25 +05:30
it('sets highlighted row if hash exists in location object', done => {
vm.$props.shouldShow = true;
2018-12-05 23:21:45 +05:30
2018-12-13 13:39:08 +05:30
vm.$nextTick()
2018-12-05 23:21:45 +05:30
.then(() => {
2018-12-23 12:14:25 +05:30
expect(vm.$store.state.diffs.highlightedRow).toBe('ABC_123');
2018-12-05 23:21:45 +05:30
})
.then(done)
.catch(done.fail);
});
});