Skip to content

Commit

Permalink
improve codecoverage
Browse files Browse the repository at this point in the history
  • Loading branch information
erossignon committed Jun 5, 2023
1 parent 14c4051 commit b96cec0
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 32 deletions.
1 change: 1 addition & 0 deletions packages/node-opcua-aggregates/.mocharc.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
require:
- ts-node/register
- source-map-support/register
extension:
- ts
- js
Expand Down
16 changes: 0 additions & 16 deletions packages/node-opcua-aggregates/nyc.config.js

This file was deleted.

2 changes: 1 addition & 1 deletion packages/node-opcua-aggregates/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"types": "./dist/index.d.ts",
"scripts": {
"build": "tsc -b",
"test": "mocha",
"test": "mocha test/*.ts",
"lint": "eslint source test",
"format": "prettier --write source test",
"clean": "npx rimraf node_modules dist *.tsbuildinfo"
Expand Down
10 changes: 5 additions & 5 deletions packages/node-opcua-aggregates/source/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ function processAggregateData(

const results: DataValue[] = [];

const tstart = startDate.getTime();
const tend = endDate.getTime();
const startTime = startDate.getTime();
const endTime = endDate.getTime();

const indexHint = 0;
for (let t = tstart; t < tend; t += processingInterval) {
for (let t = startTime; t < endTime; t += processingInterval) {
const sourceTimestamp = new Date();
sourceTimestamp.setTime(t);

Expand Down Expand Up @@ -63,12 +63,12 @@ export function getAggregateData(
): void {
/* istanbul ignore next */
if (node.nodeClass !== NodeClass.Variable) {
throw new Error("node must be UAVariable");
return callback(new Error("node must be UAVariable"));
}

/* istanbul ignore next */
if (processingInterval <= 0) {
throw new Error("Invalid processing interval, shall be greater than 0");
return callback(new Error("Invalid processing interval, shall be greater than 0"));
}

const continuationPointManager = new ContinuationPointManager();
Expand Down
5 changes: 5 additions & 0 deletions packages/node-opcua-aggregates/source/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,8 @@ export * from "./common";
export * from "./average";
export * from "./read_processed_details";
export { AggregateFunction } from "node-opcua-constants";
export { getCountData } from "./count";
export { getPercentGoodData } from "./percent_good";
export { getPercentBadData } from "./percent_bad";
export { getDurationBadData } from "./duration_bad";
export { getDurationGoodData } from "./duration_good";
29 changes: 19 additions & 10 deletions packages/node-opcua-aggregates/test/test_aggregates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,25 @@ import { nodesets } from "node-opcua-nodesets";
import { generateAddressSpace } from "node-opcua-address-space/nodeJS";
import { DataType } from "node-opcua-variant";

import { AggregateFunction, getInterpolatedData, installAggregateConfigurationOptions } from "..";
import { addAggregateSupport, getAggregateConfiguration } from "..";
import { getMaxData, getMinData } from "..";
import { getAverageData } from "../source/average";
import { getCountData } from "../source/count";
import { getPercentGoodData } from "../source/percent_good";
import { getPercentBadData } from "../source/percent_bad";
import { getDurationBadData } from "../source/duration_bad";
import { getDurationGoodData } from "../source/duration_good";
import {
AggregateFunction,
getInterpolatedData,
installAggregateConfigurationOptions,
addAggregateSupport,
getAggregateConfiguration,
getMaxData,
getMinData,
getAverageData,
getCountData,
getPercentGoodData,
getPercentBadData,
getDurationBadData,
getDurationGoodData
} from "..";

import { createHistorian1, createHistorian2, createHistorian3, createHistorian4 } from "./helpers/create_historizing_variables";
import { makeDate } from "./helpers/helpers";

const _should = should;

const describe = require("node-opcua-leak-detector").describeWithLeakDetector;

Expand Down Expand Up @@ -669,7 +674,11 @@ describe("Aggregates - Function ", () => {
const startDate = makeDate("12:00:00");
const endDate = makeDate("12:01:40");

console.log("startDate = ", startDate.toISOString());
console.log("startDate = ", endDate.toISOString());

getCountData(h1, 16 * 1000, startDate, endDate, (err: Error | null, dataValues?: DataValue[]) => {

if (err) {
return done(err);
}
Expand Down

0 comments on commit b96cec0

Please sign in to comment.