UNPKG

1.58 kBJavaScriptView Raw
1/* @flow */
2
3import 'babel-polyfill'
4
5import DviToSvg from '../../src/Rules/DviToSvg'
6import { initializeRule } from '../helpers'
7
8import type { RuleDefinition } from '../helpers'
9
10async function initialize ({
11 RuleClass = DviToSvg,
12 parameters = [{
13 filePath: 'DeviceIndependentFile.dvi'
14 }],
15 ...rest }: RuleDefinition = {}) {
16 return initializeRule({ RuleClass, parameters, ...rest })
17}
18
19describe('DviToSvg', () => {
20 describe('appliesToParameters', () => {
21 it('returns true if outputFormat is \'svg\'', async (done) => {
22 const { rule, options } = await initialize({
23 options: { outputFormat: 'svg' }
24 })
25
26 expect(await DviToSvg.appliesToParameters(rule.state, 'build', 'execute', options, ...rule.parameters)).toBe(true)
27
28 done()
29 })
30
31 it('returns false if outputFormat is not \'svg\'', async (done) => {
32 const { rule, options } = await initialize({
33 options: { outputFormat: 'dvi' }
34 })
35
36 expect(await DviToSvg.appliesToParameters(rule.state, 'build', 'execute', options, ...rule.parameters)).toBe(false)
37
38 done()
39 })
40 })
41
42 describe('constructCommand', () => {
43 it('returns correct arguments and command options for dvi file.', async (done) => {
44 const { rule } = await initialize()
45
46 expect(rule.constructCommand()).toEqual({
47 args: [
48 'dvisvgm',
49 '-o',
50 '{{$DIR_0/$NAME_0.svg}}',
51 '{{$FILEPATH_0}}'
52 ],
53 cd: '$ROOTDIR',
54 severity: 'error',
55 outputs: ['$DIR_0/$NAME_0.svg']
56 })
57
58 done()
59 })
60 })
61})