-
Notifications
You must be signed in to change notification settings - Fork 13.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Oura Node): Update node for v2 api (#11604)
- Loading branch information
Showing
6 changed files
with
296 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
export const profileResponse = { | ||
id: 'some-id', | ||
age: 30, | ||
weight: 168, | ||
height: 80, | ||
biological_sex: 'male', | ||
email: 'nathan@n8n.io', | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
import type { | ||
IExecuteFunctions, | ||
IHookFunctions, | ||
ILoadOptionsFunctions, | ||
IHttpRequestMethods, | ||
INode, | ||
} from 'n8n-workflow'; | ||
import nock from 'nock'; | ||
|
||
import { setup, equalityTest, workflowToTests, getWorkflowFilenames } from '@test/nodes/Helpers'; | ||
|
||
import { profileResponse } from './apiResponses'; | ||
import { ouraApiRequest } from '../GenericFunctions'; | ||
|
||
const node: INode = { | ||
id: '2cdb46cf-b561-4537-a982-b8d26dd7718b', | ||
name: 'Oura', | ||
type: 'n8n-nodes-base.oura', | ||
typeVersion: 1, | ||
position: [0, 0], | ||
parameters: { | ||
resource: 'profile', | ||
operation: 'get', | ||
}, | ||
}; | ||
|
||
const mockThis = { | ||
helpers: { | ||
httpRequestWithAuthentication: jest | ||
.fn() | ||
.mockResolvedValue({ statusCode: 200, data: profileResponse }), | ||
}, | ||
getNode() { | ||
return node; | ||
}, | ||
getNodeParameter: jest.fn(), | ||
} as unknown as IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions; | ||
|
||
describe('Oura', () => { | ||
describe('ouraApiRequest', () => { | ||
it('should make an authenticated API request to Oura', async () => { | ||
const method: IHttpRequestMethods = 'GET'; | ||
const resource = '/usercollection/personal_info'; | ||
|
||
await ouraApiRequest.call(mockThis, method, resource); | ||
|
||
expect(mockThis.helpers.httpRequestWithAuthentication).toHaveBeenCalledWith('ouraApi', { | ||
method: 'GET', | ||
url: 'https://api.ouraring.com/v2/usercollection/personal_info', | ||
json: true, | ||
}); | ||
}); | ||
}); | ||
describe('Run Oura workflow', () => { | ||
const workflows = getWorkflowFilenames(__dirname); | ||
const tests = workflowToTests(workflows); | ||
|
||
beforeAll(() => { | ||
nock.disableNetConnect(); | ||
|
||
nock('https://api.ouraring.com/v2') | ||
.get('/usercollection/personal_info') | ||
.reply(200, profileResponse); | ||
}); | ||
|
||
afterAll(() => { | ||
nock.restore(); | ||
}); | ||
|
||
const nodeTypes = setup(tests); | ||
|
||
for (const testData of tests) { | ||
test(testData.description, async () => await equalityTest(testData, nodeTypes)); | ||
} | ||
}); | ||
}); |
Oops, something went wrong.