-
Notifications
You must be signed in to change notification settings - Fork 168
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #53 from grassedge/markdown-it-14.1.0
Bump markdown-it
- Loading branch information
Showing
3 changed files
with
10,103 additions
and
7,533 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,184 +1,185 @@ | ||
import { retrieveCodes, getCommitsFromPayload, updatedFiles } from '../src/utils' | ||
import * as process from 'process' | ||
import * as cp from 'child_process' | ||
import * as path from 'path' | ||
import { | ||
retrieveCodes, | ||
getCommitsFromPayload, | ||
updatedFiles, | ||
} from "../src/utils"; | ||
|
||
test('retrieveCodes', async() => { | ||
const codes = await retrieveCodes([ | ||
'__tests__/assets/test1.md', | ||
'__tests__/assets/test3.pu', | ||
'__tests__/assets/test5.pml', | ||
'__tests__/assets/test6.puml', | ||
'__tests__/assets/test7.plantuml', | ||
]); | ||
await expect(codes).toEqual([ | ||
{ | ||
name: 'test-1', | ||
code: `@startuml | ||
test("retrieveCodes", async () => { | ||
const codes = await retrieveCodes([ | ||
"__tests__/assets/test1.md", | ||
"__tests__/assets/test3.pu", | ||
"__tests__/assets/test5.pml", | ||
"__tests__/assets/test6.puml", | ||
"__tests__/assets/test7.plantuml", | ||
]); | ||
await expect(codes).toEqual([ | ||
{ | ||
name: "test-1", | ||
code: `@startuml | ||
A -> B: test1 | ||
@enduml | ||
`, | ||
dir: '__tests__/assets' | ||
}, | ||
{ | ||
name: 'test_2', | ||
code: `@startuml | ||
dir: "__tests__/assets", | ||
}, | ||
{ | ||
name: "test_2", | ||
code: `@startuml | ||
A -> B: test2 | ||
@enduml | ||
`, | ||
dir: '__tests__/assets' | ||
}, | ||
{ | ||
name: 'test.4', | ||
code: `@startgantt | ||
dir: "__tests__/assets", | ||
}, | ||
{ | ||
name: "test.4", | ||
code: `@startgantt | ||
[Prototype design] lasts 15 days | ||
[Test prototype] lasts 10 days | ||
@endgantt | ||
`, | ||
dir: '__tests__/assets' | ||
}, | ||
{ | ||
name: 'test3', | ||
code: `@startuml | ||
dir: "__tests__/assets", | ||
}, | ||
{ | ||
name: "test3", | ||
code: `@startuml | ||
A -> B: test3 | ||
B -> C: test3 | ||
@enduml | ||
`, | ||
dir: '__tests__/assets' | ||
}, | ||
{ | ||
name: 'test5', | ||
code: `@startuml | ||
dir: "__tests__/assets", | ||
}, | ||
{ | ||
name: "test5", | ||
code: `@startuml | ||
A -> B: test5 | ||
B -> C: test5 | ||
@enduml | ||
`, | ||
dir: '__tests__/assets' | ||
}, | ||
{ | ||
name: 'test6', | ||
code: `@startuml | ||
dir: "__tests__/assets", | ||
}, | ||
{ | ||
name: "test6", | ||
code: `@startuml | ||
A -> B: test6 | ||
B -> C: test6 | ||
@enduml | ||
`, | ||
dir: '__tests__/assets' | ||
}, | ||
{ | ||
name: 'test7', | ||
code: `@startuml | ||
dir: "__tests__/assets", | ||
}, | ||
{ | ||
name: "test7", | ||
code: `@startuml | ||
A -> B: test7 | ||
B -> C: test7 | ||
@enduml | ||
`, | ||
dir: '__tests__/assets' | ||
} | ||
]); | ||
dir: "__tests__/assets", | ||
}, | ||
]); | ||
}); | ||
|
||
test('getCommitsFromPayload', async() => { | ||
const files = await getCommitsFromPayload(octokitMock, pushEventPayloadMock); | ||
await expect(files).toEqual([ | ||
test("getCommitsFromPayload", async () => { | ||
const files = await getCommitsFromPayload(octokitMock, pushEventPayloadMock); | ||
await expect(files).toEqual([ | ||
{ | ||
files: [ | ||
{ | ||
filename: "file1.txt", | ||
}, | ||
], | ||
sha: "a", | ||
}, | ||
{ | ||
files: [ | ||
{ | ||
"files": [ | ||
{ | ||
"filename": "file1.txt", | ||
}, | ||
], | ||
"sha": "a", | ||
filename: "file1.txt", | ||
}, | ||
{ | ||
"files": [ | ||
{ | ||
"filename": "file1.txt", | ||
}, | ||
{ | ||
"filename": "file2.txt", | ||
}, | ||
], | ||
"sha": "b", | ||
} | ||
]); | ||
filename: "file2.txt", | ||
}, | ||
], | ||
sha: "b", | ||
}, | ||
]); | ||
}); | ||
|
||
test('updatedFiles', async() => { | ||
const files = await updatedFiles([ | ||
test("updatedFiles", async () => { | ||
const files = await updatedFiles([ | ||
{ | ||
files: [ | ||
{ | ||
filename: "file1.txt", | ||
}, | ||
], | ||
sha: "a", | ||
}, | ||
{ | ||
files: [ | ||
{ | ||
status: "added", | ||
filename: "file1.txt", | ||
}, | ||
{ | ||
status: "modified", | ||
filename: "file2.txt", | ||
}, | ||
{ | ||
"files": [ | ||
{ | ||
"filename": "file1.txt", | ||
}, | ||
], | ||
"sha": "a", | ||
status: "removed", | ||
filename: "file3.txt", | ||
}, | ||
{ | ||
"files": [ | ||
{ | ||
"status": "added", | ||
"filename": "file1.txt", | ||
}, | ||
{ | ||
"status": "modified", | ||
"filename": "file2.txt", | ||
}, | ||
{ | ||
"status": "removed", | ||
"filename": "file3.txt", | ||
}, | ||
{ | ||
"status": "renamed", | ||
"filename": "file4.txt", | ||
}, | ||
], | ||
"sha": "b", | ||
} | ||
]); | ||
await expect(files).toEqual([ 'file1.txt', 'file2.txt', 'file4.txt' ]); | ||
status: "renamed", | ||
filename: "file4.txt", | ||
}, | ||
], | ||
sha: "b", | ||
}, | ||
]); | ||
await expect(files).toEqual(["file1.txt", "file2.txt", "file4.txt"]); | ||
}); | ||
|
||
const octokitMock = { | ||
repos: { | ||
async getCommit({ owner, repo, ref }) { | ||
return { data: commitMocks[ref] } | ||
} | ||
} | ||
} | ||
repos: { | ||
async getCommit({ owner, repo, ref }) { | ||
return { data: commitMocks[ref] }; | ||
}, | ||
}, | ||
}; | ||
|
||
const pushEventPayloadMock = { | ||
"commits": [ | ||
{ | ||
"id": "a" | ||
}, | ||
{ | ||
"id": "b" | ||
} | ||
], | ||
"repository": { | ||
"name": "Hello-World", | ||
"owner": { | ||
"login": "Codertocat", | ||
} | ||
} | ||
commits: [ | ||
{ | ||
id: "a", | ||
}, | ||
{ | ||
id: "b", | ||
}, | ||
], | ||
repository: { | ||
name: "Hello-World", | ||
owner: { | ||
login: "Codertocat", | ||
}, | ||
}, | ||
}; | ||
|
||
const commitMocks = { | ||
a: { | ||
"sha": "a", | ||
"files": [ | ||
{ | ||
"filename": "file1.txt", | ||
} | ||
] | ||
}, | ||
b: { | ||
"sha": "b", | ||
"files": [ | ||
{ | ||
"filename": "file1.txt", | ||
}, | ||
{ | ||
"filename": "file2.txt", | ||
} | ||
] | ||
} | ||
a: { | ||
sha: "a", | ||
files: [ | ||
{ | ||
filename: "file1.txt", | ||
}, | ||
], | ||
}, | ||
b: { | ||
sha: "b", | ||
files: [ | ||
{ | ||
filename: "file1.txt", | ||
}, | ||
{ | ||
filename: "file2.txt", | ||
}, | ||
], | ||
}, | ||
}; |
Oops, something went wrong.