Skip to content

Commit

Permalink
Add a simple test for AWS Comprehend node
Browse files Browse the repository at this point in the history
  • Loading branch information
ShireenMissi committed Jul 11, 2024
1 parent de9590e commit c7af161
Show file tree
Hide file tree
Showing 2 changed files with 136 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import nock from 'nock';
import { getWorkflowFilenames, initBinaryDataService, testWorkflows } from '@test/nodes/Helpers';

const workflows = getWorkflowFilenames(__dirname);

describe('Test AWS Comprehend Node', () => {
describe('Detect Language', () => {
let mock: nock.Scope;
const now = 1683028800000;
const response = {
Languages: [
{
LanguageCode: 'en',
Score: 0.9774383902549744,
},
{
LanguageCode: 'de',
Score: 0.010717987082898617,
},
],
};
beforeAll(async () => {
jest.useFakeTimers({ doNotFake: ['nextTick'], now });

await initBinaryDataService();

nock.disableNetConnect();
const baseUrl = 'https://comprehend.eu-central-1.amazonaws.com';

mock = nock(baseUrl);
});

beforeEach(async () => {
mock.post('/').reply(200, response);
});
afterAll(() => {
nock.restore();
});

testWorkflows(workflows);
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
{
"name": "node-aws-comprehend",
"nodes": [
{
"parameters": {},
"id": "73cf15c4-15f9-43aa-a535-26d840601480",
"name": "When clicking ‘Test workflow’",
"type": "n8n-nodes-base.manualTrigger",
"position": [
820,
360
],
"typeVersion": 1
},
{
"parameters": {
"assignments": {
"assignments": [
{
"id": "51b7eee5-8cc9-4e09-a2f4-65ffb3cc17f6",
"name": "text",
"value": "This is a test.",
"type": "string"
}
]
},
"options": {}
},
"id": "76a71bac-81fe-4b28-b15b-483efa827d12",
"name": "Edit Fields",
"type": "n8n-nodes-base.set",
"typeVersion": 3.4,
"position": [
1060,
600
]
},
{
"parameters": {
"text": "={{ $json.text }}"
},
"id": "61665744-5a4e-4f49-a027-16bd527cbeb9",
"name": "AWS Comprehend",
"type": "n8n-nodes-base.awsComprehend",
"typeVersion": 1,
"position": [
1480,
440
],
"credentials": {
"aws": {
"id": "124",
"name": "AWS creds"
}
}
}
],
"pinData": {},
"connections": {
"Edit Fields": {
"main": [
[
{
"node": "AWS Comprehend",
"type": "main",
"index": 0
}
]
]
},
"When clicking ‘Test workflow’": {
"main": [
[
{
"node": "Edit Fields",
"type": "main",
"index": 0
}
]
]
}
},
"active": false,
"settings": {
"executionOrder": "v1"
},
"versionId": "21f5ca33-74a0-4e28-b4ba-b90154db8d53",
"meta": {
"templateCredsSetupCompleted": true,
"instanceId": "27cc9b56542ad45b38725555722c50a1c3fee1670bbb67980558314ee08517c4"
},
"id": "yAlSAFNzvjfThNOR",
"tags": []
}

0 comments on commit c7af161

Please sign in to comment.