Skip to content

Commit

Permalink
feat: added templates to verify
Browse files Browse the repository at this point in the history
  • Loading branch information
manchuck committed Sep 25, 2024
1 parent 4aaa381 commit 08fb306
Show file tree
Hide file tree
Showing 35 changed files with 1,458 additions and 465 deletions.
56 changes: 43 additions & 13 deletions packages/verify2/__tests__/__dataSets__/cancel.ts
Original file line number Diff line number Diff line change
@@ -1,28 +1,58 @@
import {
SDKTestCase,
keyAuth,
validateBearerAuth,
} from '../../../../testHelpers';
import {
Verify2,
} from '../../lib/';

export default [
{
label: 'cancel request',
request: ['/v2/verify/091e717f-8715-41a0-a3f0-cc04912deaa1', 'DELETE'],
response: [204],
baseUrl: 'https://api.nexmo.com',
reqHeaders: {
authorization: validateBearerAuth,
},
client: new Verify2(keyAuth),
generator: false,
error: false,
requests: [
['/v2/verify/091e717f-8715-41a0-a3f0-cc04912deaa1', 'DELETE'],
],
responses: [
[204],
],
method: 'post',
clientMethod: 'cancel',
parameters: ['091e717f-8715-41a0-a3f0-cc04912deaa1'],
expected: true,
},
{
label: 'error when request not found',
request: ['/v2/verify/091e717f-8715-41a0-a3f0-cc04912deaa1', 'DELETE'],
response: [
404,
{
title: 'Not Found',
type: 'https://developer.vonage.com/api-errors#not-found',
detail: 'Request <id> was not found or it has been verified already.',
instance: 'bf0ca0bf927b3b52e3cb03217e1a1ddf',
},
baseUrl: 'https://api.nexmo.com',
reqHeaders: {
authorization: validateBearerAuth,
},
client: new Verify2(keyAuth),
generator: false,
error: false,
requests: [
['/v2/verify/091e717f-8715-41a0-a3f0-cc04912deaa1', 'DELETE'],
],
responses: [
[
404,
{
title: 'Not Found',
type: 'https://developer.vonage.com/api-errors#not-found',
detail: 'Request <id> was not found or it has been verified already.',
instance: 'bf0ca0bf927b3b52e3cb03217e1a1ddf',
},
],
],
method: 'delete',
clientMethod: 'cancel',
parameters: ['091e717f-8715-41a0-a3f0-cc04912deaa1'],
expected: false,
},
];
] as SDKTestCase<Verify2>[];
85 changes: 55 additions & 30 deletions packages/verify2/__tests__/__dataSets__/check.ts
Original file line number Diff line number Diff line change
@@ -1,49 +1,74 @@
import { CheckCodeRequest, CheckRequestResponse } from '../../lib/types';
import {
SDKTestCase,
keyAuth,
validateBearerAuth,
} from '../../../../testHelpers';
import { Verify2 } from '../../lib';

export default [
{
label: 'check code',
request: [
'/v2/verify/091e717f-8715-41a0-a3f0-cc04912deaa1',
'POST',
{
code: '123456',
} as CheckCodeRequest,
baseUrl: 'https://api.nexmo.com',
reqHeaders: {
authorization: validateBearerAuth,
},
client: new Verify2(keyAuth),
generator: false,
error: false,
requests: [
[
'/v2/verify/091e717f-8715-41a0-a3f0-cc04912deaa1',
'POST',
{
code: '123456',
} as CheckCodeRequest,
],
],
response: [
200,
{
request_id: '091e717f-8715-41a0-a3f0-cc04912deaa1',
status: 'complete',
} as CheckRequestResponse,
responses: [
[
200,
{
request_id: '091e717f-8715-41a0-a3f0-cc04912deaa1',
status: 'complete',
} as CheckRequestResponse,
],
],
method: 'post',
clientMethod: 'checkCode',
parameters: ['091e717f-8715-41a0-a3f0-cc04912deaa1', '123456'],
expected: 'complete',
},
{
label: 'error when request not found',
request: [
'/v2/verify/091e717f-8715-41a0-a3f0-cc04912deaa1',
'POST',
{
code: '123456',
} as CheckCodeRequest,
baseUrl: 'https://api.nexmo.com',
reqHeaders: {
authorization: validateBearerAuth,
},
client: new Verify2(keyAuth),
generator: false,
error: 'Request failed with status code 404',
requests: [
[
'/v2/verify/091e717f-8715-41a0-a3f0-cc04912deaa1',
'POST',
{
code: '123456',
} as CheckCodeRequest,
],
],
response: [
404,
{
title: 'Not Found',
type: 'https://developer.vonage.com/api-errors#not-found',
detail: 'Request <id> was not found or it has been verified already.',
instance: 'bf0ca0bf927b3b52e3cb03217e1a1ddf',
},
responses: [
[
404,
{
title: 'Not Found',
type: 'https://developer.vonage.com/api-errors#not-found',
detail: 'Request <id> was not found or it has been verified already.',
instance: 'bf0ca0bf927b3b52e3cb03217e1a1ddf',
},
],
],
method: 'post',
clientMethod: 'checkCode',
parameters: ['091e717f-8715-41a0-a3f0-cc04912deaa1', '123456'],
expected: true,
error: 'Request failed with status code 404',
},
];
] as SDKTestCase<Verify2>[];
11 changes: 8 additions & 3 deletions packages/verify2/__tests__/__dataSets__/index.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
import requestTests from './verify';
import checkTests from './check';
import cancelTests from './cancel';
import templateTests from './templates';

export default [
{
label: 'Request tests',
name: 'Request tests',
tests: requestTests,
},
{
label: 'Check tests',
name: 'Check tests',
tests: checkTests,
},
{
label: 'Cancel tests',
name: 'Cancel tests',
tests: cancelTests,
},
{
name: 'Templates tests',
tests: templateTests,
}
];
Loading

0 comments on commit 08fb306

Please sign in to comment.