UNPKG

@chrispyduck/homie-sensors

Version:

Sensor library intended for ues with homie-device

49 lines 2.05 kB
"use strict"; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const AHT20_1 = __importDefault(require("./AHT20")); const chai = __importStar(require("chai")); const winston_1 = __importDefault(require("winston")); chai.use(require("chai-events")); describe("AHT20", () => { it("Reads valid data #Integration", async () => { const device = new AHT20_1.default(); const emitAssertion = chai.expect(device); emitAssertion.emit("humidity", (h) => { winston_1.default.info(`Humidity: ${h}`); chai.expect(h).to.be.within(1, 100); }); emitAssertion.emit("temperature", (t) => { winston_1.default.info(`Temperature: ${t}`); chai.expect(t).to.be.within(1, 120); }); await device.init(); await new Promise(r => setTimeout(() => r(), 1000)); winston_1.default.info(JSON.stringify({ humidity: device.humidity, temperature: device.temperature, })); }); }); //# sourceMappingURL=AHT20.tests.js.map