UNPKG

1.52 kBJavaScriptView Raw
1/* @flow */
2
3import 'babel-polyfill'
4
5import ReportLogMessages from '../../src/Rules/ReportLogMessages'
6import { initializeRule } from '../helpers'
7
8import type { RuleDefinition } from '../helpers'
9
10async function initialize ({
11 RuleClass = ReportLogMessages,
12 parameters = [{
13 filePath: 'LaTeXLog_pdfTeX.log-ParsedLaTeXLog'
14 }],
15 ...rest }: RuleDefinition = {}) {
16 return initializeRule({ RuleClass, parameters, ...rest })
17}
18
19describe('ReportLogMessages', () => {
20 describe('run', () => {
21 it('logs all messages in a parsed log file.', async (done) => {
22 const { rule } = await initialize({
23 parameters: [{
24 filePath: 'LaTeXLog_pdfTeX.log-ParsedLaTeXLog',
25 value: {
26 inputs: [],
27 outputs: [],
28 calls: [],
29 messages: [{
30 severity: 'info',
31 text: 'foo'
32 }, {
33 severity: 'warning',
34 text: 'bar'
35 }]
36 }
37 }]
38 })
39
40 expect(await rule.run()).toBe(true)
41 expect(rule.log).toHaveBeenCalledWith({
42 severity: 'info',
43 text: 'foo'
44 })
45 expect(rule.log).toHaveBeenCalledWith({
46 severity: 'warning',
47 text: 'bar'
48 })
49
50 done()
51 })
52
53 it('does not log any messages when there are none in the parsed log file.', async (done) => {
54 const { rule } = await initialize()
55
56 expect(await rule.run()).toBe(true)
57 expect(rule.log).not.toHaveBeenCalled()
58
59 done()
60 })
61 })
62})