diff --git a/packages/client/src/InfluxDBClient.ts b/packages/client/src/InfluxDBClient.ts index 4fe80edd..64f8384f 100644 --- a/packages/client/src/InfluxDBClient.ts +++ b/packages/client/src/InfluxDBClient.ts @@ -100,8 +100,8 @@ export default class InfluxDBClient { */ async *queryPoints( query: string, - database: string, - queryType: QueryType + database?: string, + queryType: QueryType = 'sql' ): AsyncGenerator { const points = this._queryApi.queryPoints( query, diff --git a/packages/client/test/integration/e2e.test.ts b/packages/client/test/integration/e2e.test.ts index 8591f18e..40593301 100644 --- a/packages/client/test/integration/e2e.test.ts +++ b/packages/client/test/integration/e2e.test.ts @@ -1,7 +1,7 @@ import {expect} from 'chai' import {InfluxDBClient, Point} from '../../src' import {rejects} from 'assert' -import {PointValues} from '../../src/PointValues' +import {PointValues} from '../../src' const getEnvVariables = () => { const { diff --git a/packages/client/test/unit/Influxdb.test.ts b/packages/client/test/unit/Influxdb.test.ts index 83d7b6be..bd294ff8 100644 --- a/packages/client/test/unit/Influxdb.test.ts +++ b/packages/client/test/unit/Influxdb.test.ts @@ -20,6 +20,7 @@ describe('InfluxDB', () => { const queryApi: QueryApi = (client as any)._queryApi const writeStub = sinon.stub(writeApi, 'doWrite') const queryStub = sinon.stub(queryApi, 'query') + const queryPointsStub = sinon.stub(queryApi, 'queryPoints') const lines = ['lpdata'] @@ -39,6 +40,15 @@ describe('InfluxDB', () => { client.query(query, 'another') expect(queryStub.calledOnceWith(query, 'another', 'sql')).to.be.true + + // queryPoints + client.queryPoints(query).next() + + expect(queryPointsStub.calledOnceWith(query, database, 'sql')).to.be.true + queryPointsStub.resetHistory() + + client.queryPoints(query, 'another').next() + expect(queryPointsStub.calledOnceWith(query, 'another', 'sql')).to.be.true }) it('throws when no database provided', async () => { diff --git a/packages/client/test/unit/util/point.test.ts b/packages/client/test/unit/util/point.test.ts index a6300b71..d91310bd 100644 --- a/packages/client/test/unit/util/point.test.ts +++ b/packages/client/test/unit/util/point.test.ts @@ -259,6 +259,7 @@ describe('point', () => { .setField('e', 3.45) .setUintegerField('f', 8) .setStringField('g', 88) + .setStringField('h', undefined) .setTimestamp(150) expect(1).deep.equals(v.getIntegerField('b')) expect('xyz').deep.equals(v.getStringField('c'))