fix(Notion Node): Tests (no-changelog) (#12196)

This commit is contained in:
Michael Kret
2024-12-13 11:06:19 +02:00
committed by GitHub
parent a53d0e131d
commit 65b8e20049
29 changed files with 4209 additions and 0 deletions

View File

@@ -0,0 +1,45 @@
import nock from 'nock';
import type { IHttpRequestMethods } from 'n8n-workflow';
import { equalityTest, setup, workflowToTests } from '@test/nodes/Helpers';
const API_RESPONSE = {
object: 'user',
id: '34a945c6-de97-4efc-90d6-6d7cc14a6583',
name: 'second',
avatar_url: null,
type: 'bot',
bot: {},
request_id: 'ad2a00c0-fa6a-4a14-bf9a-68e1715b51a1',
};
jest.mock('../../../../shared/GenericFunctions', () => {
const originalModule = jest.requireActual('../../../../shared/GenericFunctions');
return {
...originalModule,
notionApiRequest: jest.fn(async function (method: IHttpRequestMethods) {
if (method === 'GET') {
return API_RESPONSE;
}
}),
};
});
describe('Test NotionV2, user => get', () => {
const workflows = ['nodes/Notion/test/node/v2/user/get.workflow.json'];
const tests = workflowToTests(workflows);
beforeAll(() => {
nock.disableNetConnect();
});
afterAll(() => {
nock.restore();
jest.unmock('../../../../shared/GenericFunctions');
});
const nodeTypes = setup(tests);
for (const testData of tests) {
test(testData.description, async () => await equalityTest(testData, nodeTypes));
}
});