fixing for windows, and such, more test splitting

This commit is contained in:
Tyrel Souza 2023-10-20 11:32:01 -04:00
parent ddb5e1087d
commit 44c3bcb8fc
No known key found for this signature in database
GPG Key ID: F3614B02ACBE438E
3 changed files with 23 additions and 14 deletions

View File

@ -43,10 +43,12 @@ export default function parseTransducer(fileName, content, accuracy){
[, value, unit] = match;
value = parseInt(value);
}
if (unit === "SCCM") {
// SCCM and LPM are Flow
if (unit === "SCCM" || unit === "LPM") {
transducerType = "Flow";
}
if (unit === "PSIA") {
// PSIA and PSID are pressure
if (unit === "PSIA" || unit === "PSID") {
transducerType = "Pressure";
}
}

View File

@ -5,5 +5,5 @@ const file = fs.readFileSync("src/parsers/__tests__/hardware_calibration.txt", '
test('parseHardwareCalibration', () => {
const hardware = parseHardwareCalibration(file, 0.05)
console.log(hardware)
// console.log(hardware)
});

View File

@ -1,3 +1,5 @@
import {tr} from "date-fns/locale";
const fs = require('fs');
const path = require('path');
import parseTransducer from "../Transducer"
@ -20,20 +22,25 @@ function readFiles(dir) {
files.push({ filepath, name, ext, stat, content });
}
});
files.sort((a, b) => {
// natural sort alphanumeric strings
// https://stackoverflow.com/a/38641281
return a.name.localeCompare(b.name, undefined, { numeric: true, sensitivity: 'base' });
});
return files;
}
test('Can parse any Transducer Verify file', () => {
describe("Test for all files", () => {
let files = readFiles("src/parsers/__tests__/transducer_verify/");
for (const file of files) {
const transducer = parseTransducer(file.name, file.content, 0.05)
console.log(transducer)
test(`Can parse ${file.name}`, () => {
const transducers = parseTransducer(file.name, file.content, 0.05)
expect(transducers.length).toBeGreaterThan(0)
for (const transducer of transducers) {
expect(transducer).toHaveProperty("Part Number")
expect(transducer).toHaveProperty("Transducer Name")
expect(transducer).toHaveProperty("Gauge Reading")
expect(transducer).toHaveProperty("Master Value")
expect(transducer["Gauge Reading"].length).toBeGreaterThan(1);
expect(transducer["Master Value"].length).toBe(transducer["Gauge Reading"].length);
}
});
}
});
});