Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Decyjphr/merge 520 #598

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
"lint:lockfile": "lockfile-lint --path package-lock.json --type npm --validate-https --allowed-hosts npm",
"lint:engines": "check-engine",
"lint:peer": "npm ls >/dev/null",
"test:unit": "jest --roots=lib --roots=test/unit",
"test:unit:ci": "npm run test:unit --reporters=default --reporters=github-actions",
"test:unit": "jest --testRegex=test/unit/.*\\.test\\.js",
"test:me": "jest ",
"test:unit:watch": "npm run test:unit -- --watch",
"test:integration": "jest --roots=lib --roots=test/integration",
"test:integration:debug": "LOG_LEVEL=debug DEBUG=nock run-s test:integration"
"test:integration": "jest --testRegex=test/integration/.*\\.test\\.js",
"test:integration:debug": "LOG_LEVEL=debug DEBUG=nock run-s test:integration",
"test:unit:ci": "npm run test:unit --reporters=default --reporters=github-actions"
},
"author": "Yadhav Jayaraman",
"license": "ISC",
Expand Down
48 changes: 48 additions & 0 deletions test/unit/lib/plugins/autolinks.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
const Autolinks = require('../../../../lib/plugins/autolinks')

describe('Autolinks', () => {
let github

function configure (config) {
const log = { debug: jest.fn(), error: console.error }
const nop = false
return new Autolinks(nop, github, { owner: 'bkeepers', repo: 'test' }, config, log)
}

beforeEach(() => {
github = {
repos: {
listAutolinks: jest.fn().mockResolvedValue([]),
createAutolink: jest.fn().mockResolvedValue(),
deleteAutolink: jest.fn().mockResolvedValue(),
}
}
})

describe('sync', () => {
it('syncs autolinks', () => {
const plugin = configure([
{ key_prefix: 'ADD-', url_template: 'https://add/<num>' },
{ key_prefix: 'SAME-', url_template: 'https://same/<num>' },
{ key_prefix: 'NEW_URL-', url_template: 'https://new-url/<num>' },
])

github.repos.listAutolinks.mockResolvedValueOnce({
data: [
{ id: '1', key_prefix: 'SAME-', url_template: 'https://same/<num>', is_alphanumeric: true },
{ id: '2', key_prefix: 'REMOVE-', url_template: 'https://test/<num>', is_alphanumeric: true },
{ id: '3', key_prefix: 'NEW_URL-', url_template: 'https://old-url/<num>', is_alphanumeric: true },
]
})

return plugin.sync().then(() => {
expect(github.repos.createAutolink).toHaveBeenCalledWith({
key_prefix: 'ADD-',
url_template: 'https://add/<num>',
owner: 'bkeepers',
repo: 'test'
})
})
})
})
})
Loading