Skip to content

Commit

Permalink
test: add unit test to default x and y column functions
Browse files Browse the repository at this point in the history
Co-authored-by: Zoe Steinkamp <zoe.steinkamp@gmail.com>
  • Loading branch information
hoorayimhelping and zoesteinkamp committed Jul 24, 2020
1 parent 5dfa0e2 commit 82c4fa6
Showing 1 changed file with 48 additions and 1 deletion.
49 changes: 48 additions & 1 deletion ui/src/shared/utils/vis.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
// Funcs
import {parseYBounds} from 'src/shared/utils/vis'
import {
defaultXColumn,
defaultYColumn,
parseYBounds,
} from 'src/shared/utils/vis'
import {Table} from '@influxdata/giraffe'

describe('parseYBounds', () => {
it('should return null when bounds is null', () => {
Expand All @@ -19,3 +24,45 @@ describe('parseYBounds', () => {
expect(parseYBounds(['0.1', '0.6'])).toEqual([0.1, 0.6])
})
})

describe('getting default columns', () => {
const table = ({
getColumn() {
return [0, 0, 1000000]
},
getColumnName: jest.fn(),
getColumnType: columnKey => {
if (['_start', '_stop', '_time'].includes(columnKey)) {
return 'time'
}

if (columnKey === '_value') {
return 'number'
}

return 'boolean'
},
addColumn: jest.fn(),
columnKeys: [
'result',
'table',
'_start',
'_stop',
'_field',
'_measurement',
'_value',
'cpu',
'host',
'_time',
],
length: 3,
} as unknown) as Table

it('returns _time for the default x column', () => {
expect(defaultXColumn(table)).toBe('_time')
})

it('does something for the default y column', () => {
expect(defaultYColumn(table)).toBe('_value')
})
})

0 comments on commit 82c4fa6

Please sign in to comment.