-
Notifications
You must be signed in to change notification settings - Fork 50
/
Copy pathinstall.test.ts
46 lines (43 loc) · 1.6 KB
/
install.test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import {notStrictEqual, strictEqual} from "assert";
import chai from "chai";
import Vue from "vue/dist/vue.min";
import VueLogger from "../src/index";
import {LogLevels} from "../src/enum/log-levels";
import {ILoggerOptions} from "../src/interfaces/logger-options";
const expect = chai.expect;
describe("vue-logger.ts", () => {
test("install() should work as expected with the correct params.", () => {
const options: ILoggerOptions = {
isEnabled: true,
logLevel: LogLevels.FATAL,
separator: "|",
stringifyArguments: false,
showConsoleColors: true,
showLogLevel: false,
showMethodName: false,
};
Vue.use(VueLogger, options);
expect(Vue.$log).to.be.a("object");
strictEqual(Vue.$log.debug("debug"), undefined);
strictEqual(Vue.$log.info("info"), undefined);
strictEqual(Vue.$log.warn("warn"), undefined);
strictEqual(Vue.$log.error("error"), undefined);
expect(Vue.$log.fatal("fatal")).to.exist;
});
test("install() should throw an error with the an incorrect parameter.", () => {
const options: any = {
isEnabled: true,
logLevel: LogLevels.DEBUG,
separator: "|",
stringifyArguments: false,
showConsoleColors: true,
showLogLevel: false,
showMethodName: "wrong value for test.",
};
expect(() => {
VueLogger.install(Vue, options);
})
.to
.throw(Error, "Provided options for vuejs-logger are not valid.");
});
});