diff options
Diffstat (limited to 'spec/frontend/jobs')
-rw-r--r-- | spec/frontend/jobs/store/mutations_spec.js | 75 | ||||
-rw-r--r-- | spec/frontend/jobs/store/utils_spec.js | 7 |
2 files changed, 82 insertions, 0 deletions
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', () => { |