UNPKG

1.87 kBJavaScriptView Raw
1/* @flow */
2
3import 'babel-polyfill'
4
5import Asymptote from '../../src/Rules/Asymptote'
6import { initializeRule } from '../helpers'
7
8import type { RuleDefinition } from '../helpers'
9
10async function initialize ({
11 RuleClass = Asymptote,
12 parameters = [{
13 filePath: 'Asymptote.asy'
14 }],
15 ...rest }: RuleDefinition = {}) {
16 return initializeRule({ RuleClass, parameters, ...rest })
17}
18
19describe('Asymptote', () => {
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('Asymptote.asy')
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 Asymptote stdout.', async (done) => {
34 const { rule } = await initialize()
35 const file = await rule.getFile('Asymptote.log-ParsedAsymptoteStdOut')
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 Asymptote file.', async (done) => {
48 const { rule } = await initialize()
49
50 /* eslint no-template-curly-in-string: 0 */
51 expect(rule.constructCommand()).toEqual({
52 args: ['asy', '-vv', '{{$BASE_0}}'],
53 cd: '$ROOTDIR_0',
54 severity: 'error',
55 inputs: [
56 '$DIR_0/$NAME_0.log-ParsedAsymptoteStdOut'
57 ],
58 outputs: [
59 '$DIR_0/${NAME_0}_0.pdf',
60 '$DIR_0/${NAME_0}_0.eps',
61 '$DIR_0/$NAME_0.pre'
62 ],
63 stdout: '$DIR_0/$NAME_0.log-AsymptoteStdOut',
64 stderr: '$DIR_0/$NAME_0.log-AsymptoteStdErr'
65 })
66
67 done()
68 })
69 })
70})