Skip to content

Commit

Permalink
Merge pull request #53 from grassedge/markdown-it-14.1.0
Browse files Browse the repository at this point in the history
Bump markdown-it
  • Loading branch information
grassedge authored May 1, 2024
2 parents 17c1d0d + 216686a commit ae213c0
Show file tree
Hide file tree
Showing 3 changed files with 10,103 additions and 7,533 deletions.
277 changes: 139 additions & 138 deletions __tests__/main.test.ts
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",
},
],
},
};
Loading

0 comments on commit ae213c0

Please sign in to comment.