forked from GrantBirki/issue-template-parser
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.spec.js
More file actions
61 lines (45 loc) · 2.11 KB
/
test.spec.js
File metadata and controls
61 lines (45 loc) · 2.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import {parse} from './parse'
import {readFileSync} from 'fs'
it('readme example', async () => {
const expectedOutput = require('./fixtures/readme-example/expected.json')
const expectedOutputJson = JSON.stringify(expectedOutput, null, 2)
const body = readFileSync(
'./fixtures/readme-example/issue-body.md'
).toString()
const jsonDict = await parse(body)
expect(jsonDict).toEqual(expectedOutputJson)
})
it('multi paragraph', async () => {
const expectedOutput = require('./fixtures/multiple-paragraphs/expected.json')
const expectedOutputJson = JSON.stringify(expectedOutput, null, 2)
const body = readFileSync(
'./fixtures/multiple-paragraphs/issue-body.md'
).toString()
const jsonDict = await parse(body)
expect(jsonDict).toEqual(expectedOutputJson)
})
it('model example raw string', async () => {
const expectedOutput = require('./fixtures/model-example/expected.json')
const expectedOutputJson = JSON.stringify(expectedOutput, null, 2)
const body =
'### Model Name\r\n\r\nmy cool molecule\r\n\r\n### Model Description\r\n\r\nThis is a prediction for a super cool molecule\r\n\r\n### Ersilia ID\r\n\r\neos11aa\r\n\r\n### Publication\r\n\r\nThe following link is just an example:\r\n\r\nwww.example.com\r\n\r\n### Code\r\n\r\n_No response_\r\n\r\n### License\r\n\r\n_No response_'
const jsonDict = await parse(body)
expect(jsonDict).toEqual(expectedOutputJson)
})
it('test issue body from newly created issue', async () => {
const expectedOutput = {
model_name: 'grant test submission',
model_description: 'this is a test',
ersilia_id: 'eos123test',
slug: 'grant-test',
tags: 'a,b,c',
publication: null,
code: null,
license: 'MIT'
}
const expectedOutputJson = JSON.stringify(expectedOutput, null, 2)
const body =
'### Model Name\n\ngrant test submission\n\n### Model Description\n\nthis is a test\n\n### Ersilia ID\n\neos123test\n\n### Slug\n\ngrant-test\n\n### Tags\n\na,b,c\n\n### Publication\n\n_No response_\n\n### Code\n\n_No response_\n\n### License\n\nMIT'
const jsonDict = await parse(body)
expect(jsonDict).toEqual(expectedOutputJson)
})