1 |
|
2 |
|
3 | import 'babel-polyfill'
|
4 |
|
5 | import ReportLogMessages from '../../src/Rules/ReportLogMessages'
|
6 | import { initializeRule } from '../helpers'
|
7 |
|
8 | import type { RuleDefinition } from '../helpers'
|
9 |
|
10 | async 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 |
|
19 | describe('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 | })
|