-
Notifications
You must be signed in to change notification settings - Fork 8.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a simple test for AWS Comprehend node
- Loading branch information
1 parent
de9590e
commit c7af161
Showing
2 changed files
with
136 additions
and
0 deletions.
There are no files selected for viewing
42 changes: 42 additions & 0 deletions
42
packages/nodes-base/nodes/Aws/Comprehend/test/AwsComprehend.node.test.ts
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,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); | ||
}); | ||
}); |
94 changes: 94 additions & 0 deletions
94
packages/nodes-base/nodes/Aws/Comprehend/test/AwsComprehendTestWorkflow.json
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,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": [] | ||
} |