1 |
|
2 |
|
3 | import 'babel-polyfill'
|
4 |
|
5 | import File from '../../src/File'
|
6 | import ParseKnitrConcordance from '../../src/Rules/ParseKnitrConcordance'
|
7 | import { initializeRule } from '../helpers'
|
8 |
|
9 | import type { RuleDefinition } from '../helpers'
|
10 |
|
11 | async function initialize ({
|
12 | RuleClass = ParseKnitrConcordance,
|
13 | filePath = 'file-types/RNoWeb.Rnw',
|
14 | parameters = [{
|
15 | filePath: 'KnitrConcordance-concordance.tex'
|
16 | }],
|
17 | ...rest }: RuleDefinition = {}) {
|
18 | return initializeRule({ RuleClass, filePath, parameters, ...rest })
|
19 | }
|
20 |
|
21 | describe('ParseKnitrConcordance', () => {
|
22 | it('verifies that all concordance is successfully parsed.', async (done) => {
|
23 | const { rule } = await initialize()
|
24 | const map = {
|
25 | maps: [{
|
26 | input: 'RNoWeb.Rnw',
|
27 | output: 'RNoWeb.tex',
|
28 | mappings: [
|
29 | { input: { start: 1, end: 1 }, output: { start: 1, end: 1 } },
|
30 | { input: { start: 2, end: 2 }, output: { start: 2, end: 2 } },
|
31 | { input: { start: 3, end: 3 }, output: { start: 3, end: 3 } },
|
32 | { input: { start: 4, end: 4 }, output: { start: 4, end: 4 } },
|
33 | { input: { start: 5, end: 5 }, output: { start: 5, end: 5 } },
|
34 | { input: { start: 6, end: 6 }, output: { start: 6, end: 6 } },
|
35 | { input: { start: 7, end: 7 }, output: { start: 7, end: 7 } },
|
36 | { input: { start: 8, end: 8 }, output: { start: 8, end: 8 } },
|
37 | { input: { start: 9, end: 9 }, output: { start: 59, end: 59 } },
|
38 | { input: { start: 10, end: 10 }, output: { start: 60, end: 60 } },
|
39 | { input: { start: 11, end: 11 }, output: { start: 61, end: 61 } },
|
40 | { input: { start: 12, end: 12 }, output: { start: 62, end: 62 } },
|
41 | { input: { start: 13, end: 13 }, output: { start: 77, end: 77 } },
|
42 | { input: { start: 14, end: 14 }, output: { start: 78, end: 78 } },
|
43 | { input: { start: 15, end: 15 }, output: { start: 79, end: 79 } },
|
44 | { input: { start: 16, end: 16 }, output: { start: 80, end: 80 } },
|
45 | { input: { start: 17, end: 17 }, output: { start: 81, end: 81 } },
|
46 | { input: { start: 18, end: 18 }, output: { start: 82, end: 82 } },
|
47 | { input: { start: 19, end: 19 }, output: { start: 83, end: 83 } },
|
48 | { input: { start: 20, end: 20 }, output: { start: 90, end: 90 } }
|
49 | ]
|
50 | }]
|
51 | }
|
52 |
|
53 | await rule.parse()
|
54 |
|
55 | const parsedMap: ?File = await rule.getFile('KnitrConcordance-concordance.tex-ParsedSourceMap')
|
56 |
|
57 | expect(parsedMap).toBeDefined()
|
58 | if (!parsedMap) return
|
59 |
|
60 | expect(parsedMap.value).toEqual(map)
|
61 |
|
62 | done()
|
63 | })
|
64 | })
|