1 |
|
2 |
|
3 | import 'babel-polyfill'
|
4 |
|
5 | import Agda from '../../src/Rules/Agda'
|
6 | import { initializeRule } from '../helpers'
|
7 |
|
8 | import type { RuleDefinition } from '../helpers'
|
9 |
|
10 | async function initialize ({
|
11 | RuleClass = Agda,
|
12 | parameters = [{
|
13 | filePath: 'LiterateAgda.lagda'
|
14 | }],
|
15 | ...rest }: RuleDefinition = {}) {
|
16 | return initializeRule({ RuleClass, parameters, ...rest })
|
17 | }
|
18 |
|
19 | describe('Agda', () => {
|
20 | describe('appliesToParameters', () => {
|
21 | it('returns true if literateAgdaEngine is \'agda\'', async (done) => {
|
22 | const { rule, options } = await initialize()
|
23 |
|
24 | expect(await Agda.appliesToParameters(rule.state, 'build', 'execute', options, ...rule.parameters)).toBe(true)
|
25 |
|
26 | done()
|
27 | })
|
28 |
|
29 | it('returns false if literateAgdaEngine is not \'agda\'', async (done) => {
|
30 | const { rule, options } = await initialize({
|
31 | options: { literateAgdaEngine: 'lhs2TeX' }
|
32 | })
|
33 |
|
34 | expect(await Agda.appliesToParameters(rule.state, 'build', 'execute', options, ...rule.parameters)).toBe(false)
|
35 |
|
36 | done()
|
37 | })
|
38 | })
|
39 |
|
40 | describe('constructCommand', () => {
|
41 | it('returns correct arguments and command options for lagda file.', async (done) => {
|
42 | const { rule } = await initialize()
|
43 |
|
44 | expect(rule.constructCommand()).toEqual({
|
45 | args: ['agda', '--latex', '--latex-dir=.', '{{$BASE_0}}'],
|
46 | cd: '$ROOTDIR/$DIR_0',
|
47 | severity: 'error',
|
48 | outputs: ['$DIR_0/$NAME_0.tex', '$DIR_0/$NAME_0.agdai', '$DIR_0/agda.sty']
|
49 | })
|
50 |
|
51 | done()
|
52 | })
|
53 | })
|
54 | })
|