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 b05ab2b commit 29ed883
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 3 deletions.
4 changes: 2 additions & 2 deletions packages/client/src/InfluxDBClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ export default class InfluxDBClient {
*/
async *queryPoints(
query: string,
database: string,
queryType: QueryType
database?: string,
queryType: QueryType = 'sql'
): AsyncGenerator<PointValues, void, void> {
const points = this._queryApi.queryPoints(
query,
Expand Down
2 changes: 1 addition & 1 deletion packages/client/test/integration/e2e.test.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
10 changes: 10 additions & 0 deletions packages/client/test/unit/Influxdb.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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']

Expand All @@ -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 () => {
Expand Down
1 change: 1 addition & 0 deletions packages/client/test/unit/util/point.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'))
Expand Down

0 comments on commit 29ed883

Please sign in to comment.