mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-20 19:32:15 +00:00
feat(Oura Node): Update node for v2 api (#11604)
This commit is contained in:
76
packages/nodes-base/nodes/Oura/test/oura.node.test.ts
Normal file
76
packages/nodes-base/nodes/Oura/test/oura.node.test.ts
Normal file
@@ -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));
|
||||
}
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user