From 802ad9f4020e595bf8fabb3466cb6525f4f8a138 Mon Sep 17 00:00:00 2001 From: Jakub Bednar Date: Mon, 18 Sep 2023 11:00:34 +0200 Subject: [PATCH] chore: test point values --- packages/client/test/unit/util/point.test.ts | 33 +++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/packages/client/test/unit/util/point.test.ts b/packages/client/test/unit/util/point.test.ts index 31fa016e..ececa45d 100644 --- a/packages/client/test/unit/util/point.test.ts +++ b/packages/client/test/unit/util/point.test.ts @@ -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('') @@ -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()) + }) }) })