UNPKG

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