From 6b75320f525f841454f1ab162d141d3610f2e77b Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Thu, 17 Oct 2019 12:07:33 +0000 Subject: Add latest changes from gitlab-org/gitlab@master --- spec/frontend/jobs/store/mutations_spec.js | 75 ++++++++++++++++++++++++++++++ spec/frontend/jobs/store/utils_spec.js | 7 +++ 2 files changed, 82 insertions(+) (limited to 'spec/frontend/jobs') diff --git a/spec/frontend/jobs/store/mutations_spec.js b/spec/frontend/jobs/store/mutations_spec.js index 6576f3d1ff2..d1ab152330e 100644 --- a/spec/frontend/jobs/store/mutations_spec.js +++ b/spec/frontend/jobs/store/mutations_spec.js @@ -80,6 +80,81 @@ describe('Jobs Store Mutations', () => { expect(stateCopy.traceSize).toEqual(511846); expect(stateCopy.isTraceComplete).toEqual(true); }); + + describe('with new job log', () => { + let stateWithNewLog; + beforeEach(() => { + gon.features = gon.features || {}; + gon.features.jobLogJson = true; + + stateWithNewLog = state(); + }); + + afterEach(() => { + gon.features.jobLogJson = false; + }); + + describe('log.lines', () => { + describe('when append is true', () => { + it('sets the parsed log ', () => { + mutations[types.RECEIVE_TRACE_SUCCESS](stateWithNewLog, { + append: true, + size: 511846, + complete: true, + lines: [ + { + offset: 1, + content: [{ text: 'Running with gitlab-runner 11.12.1 (5a147c92)' }], + }, + ], + }); + + expect(stateWithNewLog.trace).toEqual([ + { + offset: 1, + content: [{ text: 'Running with gitlab-runner 11.12.1 (5a147c92)' }], + lineNumber: 0, + }, + ]); + }); + }); + + describe('when it is defined', () => { + it('sets the parsed log ', () => { + mutations[types.RECEIVE_TRACE_SUCCESS](stateWithNewLog, { + append: false, + size: 511846, + complete: true, + lines: [ + { offset: 0, content: [{ text: 'Running with gitlab-runner 11.11.1 (5a147c92)' }] }, + ], + }); + + expect(stateWithNewLog.trace).toEqual([ + { + offset: 0, + content: [{ text: 'Running with gitlab-runner 11.11.1 (5a147c92)' }], + lineNumber: 0, + }, + ]); + }); + }); + + describe('when it is null', () => { + it('sets the default value', () => { + mutations[types.RECEIVE_TRACE_SUCCESS](stateWithNewLog, { + append: true, + html, + size: 511846, + complete: false, + lines: null, + }); + + expect(stateWithNewLog.trace).toEqual([]); + }); + }); + }); + }); }); describe('STOP_POLLING_TRACE', () => { diff --git a/spec/frontend/jobs/store/utils_spec.js b/spec/frontend/jobs/store/utils_spec.js index 9890e01460e..43dacfe622c 100644 --- a/spec/frontend/jobs/store/utils_spec.js +++ b/spec/frontend/jobs/store/utils_spec.js @@ -291,6 +291,13 @@ describe('Jobs Store Utils', () => { }); }); }); + + describe('when no data is provided', () => { + it('returns an empty array', () => { + const result = findOffsetAndRemove(); + expect(result).toEqual([]); + }); + }); }); describe('getIncrementalLineNumber', () => { -- cgit v1.2.3