"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    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) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
Object.defineProperty(exports, "__esModule", { value: true });
const chai = require("chai");
const chaiAsPromised = require("chai-as-promised");
chai.use(chaiAsPromised);
const chai_1 = require("chai");
const stats = require(".");
const promClient = require("prom-client");
describe("Prometheus Stats", () => {
    let registry;
    let statsSink;
    beforeEach(() => __awaiter(this, void 0, void 0, function* () {
        registry = new promClient.Registry();
        statsSink = new stats.PrometheusStatsSink({ registry });
    }));
    describe("counter", () => {
        let counter;
        beforeEach(() => {
            counter = statsSink.counter({
                name: "test_counter",
                help: "test counter help",
                labelNames: [],
            });
        });
        it("should handle basic methods", () => {
            counter.inc({});
            let r = registry.metrics();
            chai_1.assert.match(r, /HELP test_counter test counter help/);
            chai_1.assert.match(r, /TYPE test_counter counter/);
            chai_1.assert.match(r, /test_counter 1/);
            counter.reset({});
            r = registry.metrics();
            chai_1.assert.match(r, /test_counter 0/);
        });
    });
    describe("gauge", () => {
        let gauge;
        beforeEach(() => {
            gauge = statsSink.gauge({
                name: "test_gauge",
                help: "test gauge help",
                labelNames: [],
            });
        });
        it("should handle basic methods", () => {
            gauge.inc({});
            let r = registry.metrics();
            chai_1.assert.match(r, /HELP test_gauge test gauge help/);
            chai_1.assert.match(r, /TYPE test_gauge gauge/);
            chai_1.assert.match(r, /test_gauge 1/);
            gauge.reset({});
            r = registry.metrics();
            chai_1.assert.match(r, /test_gauge 0/);
            gauge.set({}, 50);
            r = registry.metrics();
            chai_1.assert.match(r, /test_gauge 50/);
            gauge.dec({});
            r = registry.metrics();
            chai_1.assert.match(r, /test_gauge 49/);
        });
    });
});
//# sourceMappingURL=PrometheusStatsSink.spec.js.map