-
Notifications
You must be signed in to change notification settings - Fork 200
Expand file tree
/
Copy pathrepository.test.js
More file actions
79 lines (72 loc) · 1.89 KB
/
repository.test.js
File metadata and controls
79 lines (72 loc) · 1.89 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
const Repository = require('../../../../lib/plugins/repository')
describe('Repository', () => {
const github = {
repos: {
get: jest.fn().mockResolvedValue({
data: {
topics: []
}
}),
update: jest.fn().mockResolvedValue(),
replaceAllTopics: jest.fn().mockResolvedValue()
}
}
const log = jest.fn()
log.info = jest.fn()
log.debug = jest.fn()
log.error = jest.fn()
function configure (config) {
const noop = false
const errors = []
return new Repository(noop, github, { owner: 'bkeepers', repo: 'test' }, config, 1, log, errors)
}
describe('sync', () => {
beforeEach(() => {
jest.clearAllMocks()
})
it('syncs repository settings', () => {
const plugin = configure({
name: 'test',
description: 'Hello World!',
topics: []
})
return plugin.sync().then(() => {
expect(github.repos.update).toHaveBeenCalledWith({
owner: 'bkeepers',
repo: 'test',
name: 'test',
description: 'Hello World!',
mediaType: { previews: ['nebula-preview'] }
})
})
})
it('handles renames', () => {
const plugin = configure({
name: 'new-name'
})
return plugin.sync().then(() => {
expect(github.repos.update).toHaveBeenCalledWith({
owner: 'bkeepers',
repo: 'test',
name: 'new-name',
mediaType: { previews: ['nebula-preview'] }
})
})
})
it.only('syncs topics', () => {
const plugin = configure({
topics: ['foo', 'bar']
})
return plugin.sync().then(() => {
expect(github.repos.replaceAllTopics).toHaveBeenCalledWith({
owner: 'bkeepers',
repo: 'test',
names: ['foo', 'bar'],
mediaType: {
previews: ['mercy']
}
})
})
})
})
})