@code-nl/cloud-logging
Version:
Interface over @google-cloud/logging
79 lines (60 loc) • 1.7 kB
JavaScript
const chai = require("chai");
const assert = chai.assert;
const log = require("../index");
describe("Logging methods", () => {
before(() => {});
after(() => {});
it("has `debug` function", done => {
assert.isTrue(typeof log.debug === 'function');
done();
});
it("has `info` function", done => {
assert.isTrue(typeof log.info === "function");
done();
});
it("has `notice` function", done => {
assert.isTrue(typeof log.notice === "function");
done();
});
it("has `warning` function", done => {
assert.isTrue(typeof log.warning === "function");
done();
});
it("has `error` function", done => {
assert.isTrue(typeof log.error === "function");
done();
});
it("has `critical` function", done => {
assert.isTrue(typeof log.critical === "function");
done();
});
it("has `alert` function", done => {
assert.isTrue(typeof log.alert === "function");
done();
});
it("has `emergency` function", done => {
assert.isTrue(typeof log.emergency === "function");
done();
});
});
describe("Errors throwing", () => {
before(() => {});
after(() => {});
it("throws an error if not initialized", done => {
assert.throws(() => {
log.info("this log message should throw an error because the logger is not initialized");
}, Error);
done();
});
it("throws an error if message (first argument) is missing", done => {
// initialize logger for all further tests
log.init("test-project", "test-logname");
assert.throws(() => {
log.info();
}, Error);
assert.throws(() => {
log.info(null, {testKey: "test value"});
}, Error);
done();
});
});