forked from justinkames/vuejs-logger
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathoutput.test.ts
51 lines (44 loc) · 1.71 KB
/
output.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
47
48
49
50
51
import chai from "chai";
import { createApp, defineComponent } from "vue";
import { LogLevels } from "../src/enum/log-levels";
import VueLogger from "../src/index";
import { ILoggerOptions } from "../src/interfaces/logger-options";
const expect = chai.expect;
describe("output", () => {
// TODO(MarcSchaetz): Test failes because mount failes. Must be evaluated, how to correctly mount.
test("Should instantiate log functions and be reachable from external functions.", (done) => {
const options = {
isEnabled: true,
logLevel: LogLevels.DEBUG,
stringifyArguments: false,
showLogLevel: false,
showMethodName: true,
separator: "|",
showConsoleColors: false,
} as ILoggerOptions;
const root = defineComponent({
template: '<div id="app"></div>',
mounted() {
this.foo();
done();
},
methods: {
foo() {
expect(Vue.$log.fatal("test")).to.exist;
expect(Vue.$log.error("error")).to.exist;
expect(Vue.$log.warn("warn")).to.exist;
expect(Vue.$log.info("info")).to.exist;
expect(Vue.$log.debug("debug")).to.exist;
externalFunction();
},
},
});
const app = createApp(root);
const Vue = app.use(VueLogger, options).config.globalProperties;
app.mount('#app');
function externalFunction(): void {
expect(Vue.$log.fatal("test")).to.exist;
expect(Vue.$log.fatal("test")).to.contains("externalFunction");
}
});
});