2017-05-02 07:03:58 -04:00
|
|
|
import Vue from 'vue';
|
|
|
|
import DeployKeysStore from '~/deploy_keys/store';
|
|
|
|
import deployKeysPanel from '~/deploy_keys/components/keys_panel.vue';
|
|
|
|
|
|
|
|
describe('Deploy keys panel', () => {
|
|
|
|
const data = getJSONFixture('deploy_keys/keys.json');
|
|
|
|
let vm;
|
|
|
|
|
2018-05-07 14:21:34 -04:00
|
|
|
beforeEach(done => {
|
2017-05-02 07:03:58 -04:00
|
|
|
const DeployKeysPanelComponent = Vue.extend(deployKeysPanel);
|
|
|
|
const store = new DeployKeysStore();
|
|
|
|
store.keys = data;
|
|
|
|
|
|
|
|
vm = new DeployKeysPanelComponent({
|
|
|
|
propsData: {
|
|
|
|
title: 'test',
|
|
|
|
keys: data.enabled_keys,
|
|
|
|
showHelpBox: true,
|
|
|
|
store,
|
2017-06-20 04:05:55 -04:00
|
|
|
endpoint: 'https://test.host/dummy/endpoint',
|
2017-05-02 07:03:58 -04:00
|
|
|
},
|
|
|
|
}).$mount();
|
|
|
|
|
|
|
|
setTimeout(done);
|
|
|
|
});
|
|
|
|
|
2018-05-07 14:21:34 -04:00
|
|
|
it('renders list of keys', () => {
|
|
|
|
expect(vm.$el.querySelectorAll('.deploy-key').length).toBe(vm.keys.length);
|
2017-05-02 07:03:58 -04:00
|
|
|
});
|
|
|
|
|
2018-05-07 14:21:34 -04:00
|
|
|
it('renders table header', () => {
|
|
|
|
const tableHeader = vm.$el.querySelector('.table-row-header');
|
|
|
|
|
|
|
|
expect(tableHeader).toExist();
|
|
|
|
expect(tableHeader.textContent).toContain('Deploy key');
|
|
|
|
expect(tableHeader.textContent).toContain('Project usage');
|
|
|
|
expect(tableHeader.textContent).toContain('Created');
|
2017-05-02 07:03:58 -04:00
|
|
|
});
|
|
|
|
|
2018-05-07 14:21:34 -04:00
|
|
|
it('renders help box if keys are empty', done => {
|
2017-05-02 07:03:58 -04:00
|
|
|
vm.keys = [];
|
|
|
|
|
|
|
|
Vue.nextTick(() => {
|
2018-05-07 14:21:34 -04:00
|
|
|
expect(vm.$el.querySelector('.settings-message')).toBeDefined();
|
2017-05-02 07:03:58 -04:00
|
|
|
|
2018-05-07 14:21:34 -04:00
|
|
|
expect(vm.$el.querySelector('.settings-message').textContent.trim()).toBe(
|
|
|
|
'No deploy keys found. Create one with the form above.',
|
|
|
|
);
|
2017-05-02 07:03:58 -04:00
|
|
|
|
|
|
|
done();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2018-05-07 14:21:34 -04:00
|
|
|
it('renders no table header if keys are empty', done => {
|
2017-05-02 07:03:58 -04:00
|
|
|
vm.keys = [];
|
|
|
|
|
|
|
|
Vue.nextTick(() => {
|
2018-05-07 14:21:34 -04:00
|
|
|
expect(vm.$el.querySelector('.table-row-header')).not.toExist();
|
2017-05-02 07:03:58 -04:00
|
|
|
|
|
|
|
done();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|