Commit 0520e228 authored by Miguel Rincon's avatar Miguel Rincon

Make changes from reviews

- Remove empty function file
- Simplify getter
- Add spec for getters
parent cd02d195
......@@ -47,8 +47,7 @@ export const fetchLogs = ({ commit, state }, podName) => {
commit(types.REQUEST_PODS_DATA);
commit(types.REQUEST_LOGS_DATA);
return requestUntilData(state.logs.endpoint, { pod_name: podName })
.then(res => res.data)
.then(data => {
.then(({ data }) => {
const { pods, logs } = data;
// Set first pod as default, if none is set
......
export const trace = state => {
if (state.logs.lines) {
return state.logs.lines.join('\n');
}
return '';
};
export const trace = state => state.logs.lines.join('\n');
// prevent babel-plugin-rewire from generating an invalid default during karma tests
export default () => {};
import logsBundle from 'ee/logs/logs_bundle';
import KubernetesLogs from '../../../../kubernetes_logs';
if (gon.features.environmentLogsUseVueUi) {
document.addEventListener('DOMContentLoaded', logsBundle);
document.addEventListener('DOMContentLoaded', () => {});
} else {
document.addEventListener('DOMContentLoaded', () => {
const kubernetesLogContainer = document.querySelector('.js-kubernetes-logs');
......
import * as getters from 'ee/logs/stores/getters';
import logsPageState from 'ee/logs/stores/state';
import { mockLines } from '../mock_data';
describe('Logs Store getters', () => {
let state;
beforeEach(() => {
state = logsPageState();
});
describe('trace', () => {
describe('when state is initialized', () => {
it('returns an empty string', () => {
expect(getters.trace(state)).toEqual('');
});
});
describe('when state logs are empty', () => {
beforeEach(() => {
state.logs.lines = [];
});
it('returns an empty string', () => {
expect(getters.trace(state)).toEqual('');
});
});
describe('when state logs are set', () => {
beforeEach(() => {
state.logs.lines = mockLines;
});
it('returns an empty string', () => {
expect(getters.trace(state)).toEqual(mockLines.join('\n'));
});
});
});
});
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment