Skip to content

Commit

Permalink
overwrote current changes with the incoming
Browse files Browse the repository at this point in the history
  • Loading branch information
decyjphr committed Feb 28, 2024
2 parents 50cdabc + 943a46b commit 7556907
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 3 deletions.
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,10 @@
"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": "jest --testRegex=test/integration/.*\\.test\\.js",
"test:integration:debug": "LOG_LEVEL=debug DEBUG=nock run-s test:integration"
},
"author": "Yadhav Jayaraman",
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'
})
})
})
})
})

0 comments on commit 7556907

Please sign in to comment.