Skip to content

Commit

Permalink
chore: test point values
Browse files Browse the repository at this point in the history
  • Loading branch information
bednar committed Sep 18, 2023
1 parent 7559f37 commit 802ad9f
Showing 1 changed file with 32 additions and 1 deletion.
33 changes: 32 additions & 1 deletion packages/client/test/unit/util/point.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,15 @@ describe('point', () => {
const p = Point.fromValues(v)
expect('a,c=d b=1 150').equals(p.toString())
})

it('as point', () => {
const v = new PointValues()
.setMeasurement('a')
.setField('b', 1)
.setTag('c', 'd')
.setTimestamp(150)
const p = v.asPoint()
expect('a,c=d b=1 150').equals(p.toString())
})
it('convert point values to point with undefined measurement', () => {
const v = new PointValues()
.setMeasurement('')
Expand All @@ -207,5 +215,28 @@ describe('point', () => {
Point.fromValues(v)
}).to.throw(`Cannot convert values to point without measurement set!`)
})
it('has fields', () => {
const v1 = new PointValues()
.setMeasurement('a')
.setTag('c', 'd')
.setTimestamp(150)
expect(false).equals(v1.hasFields())
const v2 = new PointValues()
.setMeasurement('a')
.setField('b', 1)
.setTag('c', 'd')
.setTimestamp(150)
expect(true).equals(v2.hasFields())
})
it('remove field', () => {
const v = new PointValues()
.setMeasurement('a')
.setField('b', 1)
.setTag('c', 'd')
.setTimestamp(150)
expect(true).eq(v.hasFields())
v.removeField('b')
expect(false).equals(v.hasFields())
})
})
})

0 comments on commit 802ad9f

Please sign in to comment.