Skip to content

Commit

Permalink
fix: fix typo to check against mainColumnName correctly (#735)
Browse files Browse the repository at this point in the history
  • Loading branch information
TCL735 authored Feb 10, 2022
1 parent 14b1a0e commit ed0b4cd
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 4 deletions.
2 changes: 1 addition & 1 deletion giraffe/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@influxdata/giraffe",
"version": "2.24.2",
"version": "2.24.3",
"main": "dist/index.js",
"module": "dist/index.js",
"license": "MIT",
Expand Down
86 changes: 85 additions & 1 deletion giraffe/src/utils/normalizeConfig.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,61 @@ describe('normalizeConfig', () => {
})
})

it('overrides the "lowerColumnName" and "upperColumnName" when they match "mainColumnName"', () => {
it('overrides the "lowerColumnName" when it matches "mainColumnName"', () => {
const mainColumnName = 'mean'
const config = {
layers: [
{
type: 'band',
x: '_time',
y: '_value',
fill: ['result', '_field', '_measurement', 'cpu', 'host'],
mainColumnName,
lowerColumnName: mainColumnName,
},
],
} as Config
expect(normalizeConfig(config)).toEqual({
...config,
layers: [
{
...config.layers[0],
upperColumnName: '',
mainColumnName,
lowerColumnName: '',
},
],
})
})

it('overrides the "upperColumnName" when it matches "mainColumnName"', () => {
const mainColumnName = 'mean'
const config = {
layers: [
{
type: 'band',
x: '_time',
y: '_value',
fill: ['result', '_field', '_measurement', 'cpu', 'host'],
upperColumnName: mainColumnName,
mainColumnName,
},
],
} as Config
expect(normalizeConfig(config)).toEqual({
...config,
layers: [
{
...config.layers[0],
upperColumnName: '',
mainColumnName,
lowerColumnName: '',
},
],
})
})

it('overrides the "lowerColumnName" and "upperColumnName" when they both match "mainColumnName"', () => {
const mainColumnName = 'mean'
const config = {
layers: [
Expand Down Expand Up @@ -92,6 +146,36 @@ describe('normalizeConfig', () => {
],
})
})

it('allows lowerColumnName and upperColumnName to match if they do not match mainColumnName', () => {
const upperColumnName = 'upperandlower'
const mainColumnName = 'mean'
const lowerColumnName = upperColumnName
const config = {
layers: [
{
type: 'band',
x: '_time',
y: '_value',
fill: ['result', '_field', '_measurement', 'cpu', 'host'],
upperColumnName,
mainColumnName,
lowerColumnName,
},
],
} as Config
expect(normalizeConfig(config)).toEqual({
...config,
layers: [
{
...config.layers[0],
upperColumnName,
mainColumnName,
lowerColumnName,
},
],
})
})
})

/*
Expand Down
2 changes: 1 addition & 1 deletion giraffe/src/utils/normalizeConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export const normalizeLayers = (layers: LayerConfig[]): LayerConfig[] =>
if (!upperColumnName || upperColumnName === layerConfig.mainColumnName) {
upperColumnName = ''
}
if (!lowerColumnName || lowerColumnName === layerConfig.upperColumnName) {
if (!lowerColumnName || lowerColumnName === layerConfig.mainColumnName) {
lowerColumnName = ''
}
return {...layerConfig, upperColumnName, lowerColumnName}
Expand Down
2 changes: 1 addition & 1 deletion stories/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@influxdata/giraffe-stories",
"version": "2.24.2",
"version": "2.24.3",
"license": "MIT",
"repository": {
"type": "git",
Expand Down

0 comments on commit ed0b4cd

Please sign in to comment.