forge-atlas-fetch
Advanced tools
Comparing version 1.0.52 to 1.0.53
@@ -13,42 +13,151 @@ "use strict"; | ||
const _1 = require("./"); | ||
const fetch_confluence_1 = require("fetch-confluence"); | ||
const mockFetch = global['fetch']; | ||
beforeEach(() => { | ||
mockFetch.resetMocks(); | ||
}); | ||
const checkFetchInteraction = (url, payload) => { | ||
expect(mockFetch.mock.calls.length).toEqual(1); | ||
expect(mockFetch.mock.calls[0][0]).toEqual(url); | ||
expect(mockFetch.mock.calls[0][1]).toStrictEqual(expect.objectContaining(payload)); | ||
}; | ||
describe('forge', () => { | ||
describe('confluence', () => { | ||
beforeEach(() => { | ||
mockFetch.resetMocks(); | ||
describe('content API', () => { | ||
describe('GET', () => { | ||
it('should allow to call the api as an app', () => __awaiter(void 0, void 0, void 0, function* () { | ||
const mockResponse = { ok: true, Id: '123' }; | ||
mockFetch.mockResponseOnce(JSON.stringify(mockResponse)); | ||
const response = yield _1.default.confluence().asApp().content().comAtlassianConfluencePluginsRestapiResourcesContentResourceGetContentByIdGet({ id: 'sample' }); | ||
expect(response).toStrictEqual(expect.objectContaining(mockResponse)); | ||
checkFetchInteraction('/rest/api/content/sample', { | ||
method: 'GET', | ||
headers: {}, | ||
body: undefined, | ||
}); | ||
})); | ||
it('should allow to call the api as a user', () => __awaiter(void 0, void 0, void 0, function* () { | ||
const mockResponse = { ok: true, Id: '123' }; | ||
mockFetch.mockResponseOnce(JSON.stringify(mockResponse)); | ||
const response = yield _1.default.confluence().asUser().content().comAtlassianConfluencePluginsRestapiResourcesContentResourceGetContentByIdGet({ id: 'sample' }); | ||
expect(response).toStrictEqual(expect.objectContaining(mockResponse)); | ||
checkFetchInteraction('/rest/api/content/sample', { | ||
method: 'GET', | ||
headers: {}, | ||
body: undefined, | ||
}); | ||
})); | ||
}); | ||
describe('POST', () => { | ||
it('should allow to call the api as an app', () => __awaiter(void 0, void 0, void 0, function* () { | ||
const mockResponse = { ok: true, Id: '123' }; | ||
mockFetch.mockResponseOnce(JSON.stringify(mockResponse)); | ||
const payload = { | ||
title: 'title', | ||
type: fetch_confluence_1.ContentCreateTypeEnum.Page, | ||
space: { | ||
key: 'KEY' | ||
}, | ||
body: {} | ||
}; | ||
const response = yield _1.default.confluence().asApp().content().comAtlassianConfluencePluginsRestapiResourcesContentResourceCreateContentPost({ | ||
ContentCreate: payload | ||
}); | ||
expect(response).toStrictEqual(expect.objectContaining(mockResponse)); | ||
checkFetchInteraction('/rest/api/content', { | ||
method: 'POST', | ||
headers: { | ||
'Content-Type': 'application/json', | ||
}, | ||
body: JSON.stringify(payload), | ||
}); | ||
})); | ||
it('should allow to call the api as a user', () => __awaiter(void 0, void 0, void 0, function* () { | ||
const mockResponse = { ok: true, Id: '123' }; | ||
mockFetch.mockResponseOnce(JSON.stringify(mockResponse)); | ||
const payload = { | ||
title: 'title', | ||
type: fetch_confluence_1.ContentCreateTypeEnum.Page, | ||
space: { | ||
key: 'KEY' | ||
}, | ||
body: {} | ||
}; | ||
const response = yield _1.default.confluence().asUser().content().comAtlassianConfluencePluginsRestapiResourcesContentResourceCreateContentPost({ | ||
ContentCreate: payload | ||
}); | ||
expect(response).toStrictEqual(expect.objectContaining(mockResponse)); | ||
checkFetchInteraction('/rest/api/content', { | ||
method: 'POST', | ||
headers: { | ||
'Content-Type': 'application/json', | ||
}, | ||
body: JSON.stringify(payload), | ||
}); | ||
})); | ||
}); | ||
}); | ||
it('should allow to call the api as an app - content', () => __awaiter(void 0, void 0, void 0, function* () { | ||
const mockResponse = { ok: true, Id: '123' }; | ||
mockFetch.mockResponseOnce(JSON.stringify(mockResponse)); | ||
const response = yield _1.default.confluence().asApp().content().comAtlassianConfluencePluginsRestapiResourcesContentResourceGetContentByIdGet({ id: 'sample' }); | ||
expect(mockFetch.mock.calls.length).toEqual(1); | ||
expect(mockFetch.mock.calls[0][0]).toEqual('/rest/api/content/sample'); | ||
expect(response).toStrictEqual(expect.objectContaining(mockResponse)); | ||
})); | ||
it('should allow to call the api as a user - content', () => __awaiter(void 0, void 0, void 0, function* () { | ||
const mockResponse = { ok: true, Id: '123' }; | ||
mockFetch.mockResponseOnce(JSON.stringify(mockResponse)); | ||
const response = yield _1.default.confluence().asUser().content().comAtlassianConfluencePluginsRestapiResourcesContentResourceGetContentByIdGet({ id: 'sample' }); | ||
expect(mockFetch.mock.calls.length).toEqual(1); | ||
expect(mockFetch.mock.calls[0][0]).toEqual('/rest/api/content/sample'); | ||
expect(response).toStrictEqual(expect.objectContaining(mockResponse)); | ||
})); | ||
}); | ||
describe('jira', () => { | ||
beforeEach(() => { | ||
mockFetch.resetMocks(); | ||
describe('epic API', () => { | ||
describe('GET', () => { | ||
it('should allow to call the api as an app', () => __awaiter(void 0, void 0, void 0, function* () { | ||
const mockResponse = { ok: true, Id: '123' }; | ||
mockFetch.mockResponseOnce(JSON.stringify(mockResponse)); | ||
const response = yield _1.default.jira().asApp().epic().getEpic({ epicIdOrKey: 'XEN-123' }); | ||
expect(response).toStrictEqual(JSON.stringify(mockResponse)); | ||
expect(JSON.parse(response).ok).toBe(true); | ||
checkFetchInteraction('/rest/api/rest/agile/1.0/epic/XEN-123', { | ||
method: 'GET', | ||
headers: {}, | ||
body: undefined, | ||
}); | ||
})); | ||
it('should allow to call the api as a user', () => __awaiter(void 0, void 0, void 0, function* () { | ||
const mockResponse = { ok: true, Id: '123' }; | ||
mockFetch.mockResponseOnce(JSON.stringify(mockResponse)); | ||
const response = yield _1.default.jira().asUser().epic().getEpic({ epicIdOrKey: 'XEN-123' }); | ||
expect(response).toStrictEqual(JSON.stringify(mockResponse)); | ||
expect(JSON.parse(response).ok).toBe(true); | ||
checkFetchInteraction('/rest/api/rest/agile/1.0/epic/XEN-123', { | ||
method: 'GET', | ||
headers: {}, | ||
body: undefined, | ||
}); | ||
})); | ||
}); | ||
describe('POST', () => { | ||
it('should allow to call the api as an app', () => __awaiter(void 0, void 0, void 0, function* () { | ||
mockFetch.mockResponseOnce(); | ||
const payload = { issues: ['XEN-123'] }; | ||
yield _1.default.jira().asApp().epic().moveIssuesToEpic({ | ||
MoveIssuesToBacklog: { issues: ['XEN-123'] }, | ||
epicIdOrKey: 'XEN' | ||
}); | ||
checkFetchInteraction('/rest/api/rest/agile/1.0/epic/XEN/issue', { | ||
method: 'POST', | ||
headers: { | ||
'Content-Type': 'application/json', | ||
}, | ||
body: JSON.stringify(payload), | ||
}); | ||
})); | ||
it('should allow to call the api as a user', () => __awaiter(void 0, void 0, void 0, function* () { | ||
mockFetch.mockResponseOnce(); | ||
const payload = { issues: ['XEN-123'] }; | ||
yield _1.default.jira().asUser().epic().moveIssuesToEpic({ | ||
MoveIssuesToBacklog: { issues: ['XEN-123'] }, | ||
epicIdOrKey: 'XEN' | ||
}); | ||
checkFetchInteraction('/rest/api/rest/agile/1.0/epic/XEN/issue', { | ||
method: 'POST', | ||
headers: { | ||
'Content-Type': 'application/json', | ||
}, | ||
body: JSON.stringify(payload), | ||
}); | ||
})); | ||
}); | ||
}); | ||
it('should allow to call the api as an app - backlog', () => __awaiter(void 0, void 0, void 0, function* () { | ||
mockFetch.mockResponseOnce(); | ||
yield _1.default.jira().asApp().backlog().moveIssuesToBacklog({ MoveIssuesToBacklog: { issues: ['XEN-123'] } }); | ||
expect(mockFetch.mock.calls.length).toEqual(1); | ||
expect(mockFetch.mock.calls[0][0]).toEqual('/rest/api/rest/agile/1.0/backlog/issue'); | ||
})); | ||
it('should allow to call the api as a user - backlog', () => __awaiter(void 0, void 0, void 0, function* () { | ||
mockFetch.mockResponseOnce(); | ||
yield _1.default.jira().asUser().backlog().moveIssuesToBacklog({ MoveIssuesToBacklog: { issues: ['XEN-123'] } }); | ||
expect(mockFetch.mock.calls.length).toEqual(1); | ||
expect(mockFetch.mock.calls[0][0]).toEqual('/rest/api/rest/agile/1.0/backlog/issue'); | ||
})); | ||
}); | ||
}); |
{ | ||
"name": "forge-atlas-fetch", | ||
"version": "1.0.52", | ||
"version": "1.0.53", | ||
"license": "MIT", | ||
@@ -28,6 +28,6 @@ "main": "dist/index", | ||
"dependencies": { | ||
"fetch-confluence": "^1.0.52", | ||
"fetch-jira": "^1.0.52" | ||
"fetch-confluence": "^1.0.53", | ||
"fetch-jira": "^1.0.53" | ||
}, | ||
"gitHead": "c61634d5715ae88ed3efe8e08e9d9b60ee6260b6" | ||
"gitHead": "a830848ab0947cd7c3f3a0d98ecd453d99f916f4" | ||
} |
20855
405
Updatedfetch-confluence@^1.0.53
Updatedfetch-jira@^1.0.53