-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgithub.test.ts
More file actions
64 lines (61 loc) · 2.4 KB
/
github.test.ts
File metadata and controls
64 lines (61 loc) · 2.4 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
62
63
64
import { describe, expect, usingHar } from '../../har-fixture'
// must import fixture **first** for mocks, the `expect` keeps biome from changing sort-order
expect
import { EnhancerRegistry } from '../../../src/lib/registries'
describe('github', () => {
usingHar('gh_pr').it('should create the correct spot object', async () => {
const enhancers = new EnhancerRegistry()
const textareas = document.querySelectorAll('textarea')
expect(textareas.length).toBe(2)
expect(enhancers.tryToEnhance(textareas[0]!)).toBeNull()
expect(enhancers.tryToEnhance(textareas[1]!)?.spot).toMatchInlineSnapshot(`
{
"domain": "github.com",
"number": 517,
"slug": "diffplug/selfie",
"type": "GH_PR_ADD_COMMENT",
"unique_key": "github.com:diffplug/selfie:517",
}
`)
})
usingHar('gh_new_pr').it('should create the correct spot object', async () => {
const enhancers = new EnhancerRegistry()
const textareas = document.querySelectorAll('textarea')
expect(textareas.length).toBe(2)
expect(enhancers.tryToEnhance(textareas[0]!)?.spot).toMatchInlineSnapshot(`
{
"domain": "github.com",
"slug": "diffplug/selfie/main...cavia-porcellus:selfie:main",
"type": "GH_PR_NEW_COMMENT",
"unique_key": "github.com:diffplug/selfie/main...cavia-porcellus:selfie:main",
}
`)
})
usingHar('gh_issue').it('should create the correct spot object', async () => {
const enhancers = new EnhancerRegistry()
const textareas = document.querySelectorAll('textarea')
expect(textareas.length).toBe(1)
expect(enhancers.tryToEnhance(textareas[0]!)?.spot).toMatchInlineSnapshot(`
{
"domain": "github.com",
"number": 523,
"slug": "diffplug/selfie",
"type": "GH_ISSUE_ADD_COMMENT",
"unique_key": "github.com:diffplug/selfie:523",
}
`)
})
usingHar('gh_new_issue').it('should create the correct spot object', async () => {
const enhancers = new EnhancerRegistry()
const textareas = document.querySelectorAll('textarea')
expect(textareas.length).toBe(1)
expect(enhancers.tryToEnhance(textareas[0]!)?.spot).toMatchInlineSnapshot(`
{
"domain": "github.com",
"slug": "diffplug/selfie",
"type": "GH_ISSUE_NEW_COMMENT",
"unique_key": "github.com:diffplug/selfie:new",
}
`)
})
})