1 |
|
2 |
|
3 | import 'babel-polyfill'
|
4 |
|
5 | import MetaPost from '../../src/Rules/MetaPost'
|
6 | import { initializeRule } from '../helpers'
|
7 |
|
8 | import type { RuleDefinition } from '../helpers'
|
9 |
|
10 | async function initialize ({
|
11 | RuleClass = MetaPost,
|
12 | parameters = [{
|
13 | filePath: 'MetaPost.mp'
|
14 | }],
|
15 | ...rest }: RuleDefinition = {}) {
|
16 | return initializeRule({ RuleClass, parameters, ...rest })
|
17 | }
|
18 |
|
19 | describe('MetaPost', () => {
|
20 | describe('getFileActions', () => {
|
21 | it('returns a run action for an Aymptote file.', async (done) => {
|
22 | const { rule } = await initialize()
|
23 | const file = await rule.getFile('MetaPost.mp')
|
24 |
|
25 | if (file) {
|
26 | const actions = await rule.getFileActions(file)
|
27 | expect(actions).toEqual(['run'])
|
28 | }
|
29 |
|
30 | done()
|
31 | })
|
32 |
|
33 | it('returns a updateDependencies action for parsed file listing.', async (done) => {
|
34 | const { rule } = await initialize()
|
35 | const file = await rule.getFile('MetaPost.fls-ParsedFileListing')
|
36 |
|
37 | if (file) {
|
38 | const actions = await rule.getFileActions(file)
|
39 | expect(actions).toEqual(['updateDependencies'])
|
40 | }
|
41 |
|
42 | done()
|
43 | })
|
44 | })
|
45 |
|
46 | describe('constructCommand', () => {
|
47 | it('returns correct arguments and command options for MetaPost file.', async (done) => {
|
48 | const { rule } = await initialize()
|
49 |
|
50 | expect(rule.constructCommand()).toEqual({
|
51 | args: [
|
52 | 'mpost',
|
53 | '-file-line-error',
|
54 | '-interaction=batchmode',
|
55 | '-recorder',
|
56 | '{{$BASE_0}}'
|
57 | ],
|
58 | cd: '$ROOTDIR_0',
|
59 | severity: 'error',
|
60 | inputs: ['$DIR_0/$NAME_0.fls-ParsedFileListing'],
|
61 | outputs: ['$DIR_0/$NAME_0.fls', '$DIR_0/$NAME_0.log']
|
62 | })
|
63 |
|
64 | done()
|
65 | })
|
66 | })
|
67 | })
|