|
| 1 | +import { parseFixture } from './support/fixtures'; |
| 2 | + |
| 3 | +import { parseData } from '../src/browser'; |
| 4 | + |
| 5 | +describe('formatData', () => { |
| 6 | + let tableDef, data; |
| 7 | + |
| 8 | + before(() => { |
| 9 | + const contents = parseFixture('workflow-engine.log.2017-09-25'); |
| 10 | + tableDef = parseData(contents); |
| 11 | + data = tableDef.data; |
| 12 | + }); |
| 13 | + |
| 14 | + describe('headers', () => { |
| 15 | + it('is set', () => { |
| 16 | + expect(tableDef.headers).to.eql(['Timestamp', 'Level', 'Message']); |
| 17 | + }); |
| 18 | + }); |
| 19 | + |
| 20 | + describe('columnWidth', () => { |
| 21 | + it('sets to the maximum width', () => { |
| 22 | + const { columnWidth } = tableDef; |
| 23 | + expect(columnWidth[0]).to.eql(24); |
| 24 | + expect(columnWidth[1]).to.eql(5); |
| 25 | + expect(columnWidth[2]).to.eql(5325); |
| 26 | + }); |
| 27 | + }); |
| 28 | + |
| 29 | + describe('data', () => { |
| 30 | + it('has only 3 columns', () => { |
| 31 | + expect(data[0].length).to.eql(3); |
| 32 | + }); |
| 33 | + |
| 34 | + it('extracts timestamp', () => { |
| 35 | + expect(data[0][0]).to.eql('2017-09-25T22:48:38.035Z'); |
| 36 | + }); |
| 37 | + |
| 38 | + it('extracts level', () => { |
| 39 | + expect(data[0][1]).to.eql('{cyan-fg}debug{/cyan-fg}'); |
| 40 | + }); |
| 41 | + |
| 42 | + it('extracts message', () => { |
| 43 | + expect(data[0][2]).to.eql('Updated instance \'hemo\' with attributes'); |
| 44 | + }); |
| 45 | + }); |
| 46 | + |
| 47 | + describe('rawData', () => { |
| 48 | + it('keeps object', () => { |
| 49 | + expect(tableDef.rawData[0].data.to.currentState).to.eql('resultPending'); |
| 50 | + }); |
| 51 | + }); |
| 52 | +}); |
0 commit comments