UNPKG

isoxml-angular

Version:

JavaScript library to parse and generate ISOXML (ISO11783-10) files

79 lines (78 loc) 4.29 kB
"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); const ISOXMLManager_1 = require("./ISOXMLManager"); const utils_1 = require("./utils"); describe('Utils', () => { it('constructValueInformation', () => __awaiter(void 0, void 0, void 0, function* () { const valueInfo = (0, utils_1.constructValueInformation)('0001'); expect(valueInfo.DDIString).toBe('0001'); expect(valueInfo.DDINumber).toBe(1); expect(valueInfo.DDEntityName).toBe('Setpoint Volume Per Area Application Rate as [mm³/m²]'); expect(valueInfo.unit).toBe('mm³/m²'); expect(valueInfo.numberOfDecimals).toBe(2); expect(valueInfo.offset).toBe(0); expect(valueInfo.scale).toBe(0.01); expect(valueInfo.isProprietary).toBe(false); })); it('constructValueInformation with ValuePresentation', () => __awaiter(void 0, void 0, void 0, function* () { const isoxmlManager = new ISOXMLManager_1.ISOXMLManager(); const valuePresentation = isoxmlManager.createEntityFromAttributes("VPN" /* TAGS.ValuePresentation */, { Offset: 0, Scale: 0.0001, NumberOfDecimals: 1, UnitDesignator: 'l/h' }); const valueInfo = (0, utils_1.constructValueInformation)('0001', valuePresentation); expect(valueInfo.DDIString).toBe('0001'); expect(valueInfo.DDINumber).toBe(1); expect(valueInfo.DDEntityName).toBe('Setpoint Volume Per Area Application Rate as [mm³/m²]'); expect(valueInfo.unit).toBe('l/h'); expect(valueInfo.numberOfDecimals).toBe(1); expect(valueInfo.offset).toBe(0); expect(valueInfo.scale).toBe(0.0001); expect(valueInfo.isProprietary).toBe(false); })); it('constructValueInformation with ValuePresentation without unit', () => __awaiter(void 0, void 0, void 0, function* () { const isoxmlManager = new ISOXMLManager_1.ISOXMLManager(); const valuePresentation = isoxmlManager.createEntityFromAttributes("VPN" /* TAGS.ValuePresentation */, { Offset: 0, Scale: 0.0001, NumberOfDecimals: 1 }); const valueInfo = (0, utils_1.constructValueInformation)('0001', valuePresentation); expect(valueInfo.unit).toBe(''); })); it('constructValueInformation with DeviceProcessData', () => __awaiter(void 0, void 0, void 0, function* () { const isoxmlManager = new ISOXMLManager_1.ISOXMLManager(); const dpd = isoxmlManager.createEntityFromAttributes("DPD" /* TAGS.DeviceProcessData */, { DeviceProcessDataObjectId: 0, DeviceProcessDataDDI: 'FFFF', DeviceProcessDataProperty: 1, DeviceProcessDataTriggerMethods: 0, DeviceProcessDataDesignator: 'Test process' }); const valueInfo = (0, utils_1.constructValueInformation)('FFFF', null, dpd); expect(valueInfo.DDIString).toBe('FFFF'); expect(valueInfo.DDINumber).toBe(0xFFFF); expect(valueInfo.DDEntityName).toBe('Test process'); })); it('constructValueInformation - unknown DDEntity', () => __awaiter(void 0, void 0, void 0, function* () { const valueInfo = (0, utils_1.constructValueInformation)('FFFF'); expect(valueInfo.DDIString).toBe('FFFF'); expect(valueInfo.DDINumber).toBe(65535); expect(valueInfo.DDEntityName).toBe(''); expect(valueInfo.unit).toBe(''); expect(valueInfo.numberOfDecimals).toBe(-0); expect(valueInfo.offset).toBe(0); expect(valueInfo.scale).toBe(1); })); });