Skip to content

Commit 450bda9

Browse files
authored
SWI-5430 Add Prism Mock Tests (#31)
* SWI-5429 Update Test Suite and Workflows * update template * remove matrix from smoke tests * add unit tests for calls, conferences, recordings * update method names * use nes asserts from extended library * media and messages * update asserts with ! * update api error tests * more mock tests * add jest-extended * update tnl tests * messages tests * remove unnecessary globalThis * more globalThis removal * update to 200 * update bw spec * add prism to workflows * move prism to one step * update matrices * run prism in another shell * why is node 16 back * run tests fr this time * update package template * update readme to remove node 16 * regenerate * specify bash to hopefully work on windows * does npm work? * update readme
1 parent 40b5980 commit 450bda9

33 files changed

+1241
-229
lines changed

.github/workflows/deploy.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,15 @@ jobs:
4646
- name: Setup Node
4747
uses: actions/setup-node@v4
4848
with:
49-
node-version: 18
49+
node-version: 22
5050
registry-url: "https://registry.npmjs.org"
5151

5252
- name: Install Packages and Test
5353
run: |
5454
yarn
55-
yarn test-unit
55+
npm install -g @stoplight/prism-cli
56+
prism mock ./bandwidth.yml & yarn test-unit
57+
shell: bash
5658

5759
- name: Publish npm Package
5860
run: |

.github/workflows/test-nightly.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ jobs:
3737
- name: Setup Node
3838
uses: actions/setup-node@v4
3939
with:
40-
node-version: 20
40+
node-version: 22
4141

4242
- name: Install Packages and Test
4343
run: |

.github/workflows/test-pr.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
strategy:
3333
matrix:
3434
os: [windows-2022, windows-2019, ubuntu-20.04, ubuntu-22.04]
35-
node-version: [16, 18, 20, 22]
35+
node-version: [18, 20, 22]
3636
fail-fast: false
3737
steps:
3838
- name: Checkout
@@ -46,6 +46,8 @@ jobs:
4646
- name: Install Packages and Test
4747
run: |
4848
yarn
49-
yarn test-unit
49+
npm install -g @stoplight/prism-cli
50+
prism mock ./bandwidth.yml & yarn test-unit
5051
env:
5152
OPERATING_SYSTEM: ${{ matrix.os }}
53+
shell: bash

README.md

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,37 @@
11
## bandwidth-sdk
22

3-
[![Tests](https://github.com/Bandwidth/node-sdk/actions/workflows/test-nightly.yml/badge.svg)](https://github.com/Bandwidth/node-sdk/actions/workflows/test-nightly.yml)
3+
[![Deploy](https://github.com/Bandwidth/node-sdk/actions/workflows/deploy.yml/badge.svg)](https://github.com/Bandwidth/node-sdk/actions/workflows/deploy.yml)
44

55
### Test Matrix
66
| **OS** | **Node** |
77
|:---:|:---:|
8-
| Windows 2019 | 16, 18, 20, 22 |
9-
| Windows 2022 | 16, 18, 20, 22 |
10-
| Ubuntu 20.04 | 16, 18, 20, 22 |
11-
| Ubuntu 22.04 | 16, 18, 20, 22 |
8+
| Windows 2019 | 18, 20, 22 |
9+
| Windows 2022 | 18, 20, 22 |
10+
| Ubuntu 20.04 | 18, 20, 22 |
11+
| Ubuntu 22.04 | 18, 20, 22 |
1212

1313
#### Available on NPM
1414
```
1515
npm install bandwidth-sdk
1616
```
1717

18+
19+
#### To Run Unit Tests Locally
20+
21+
1. Install Prism
22+
```bash
23+
npm install -g @stoplight/prism-cli
24+
```
25+
2. Start Prism Mock Server with the OpenAPI Spec
26+
```bash
27+
prism mock bandwidth.yml
28+
```
29+
3. Run Tests
30+
```bash
31+
npm run test-unit
32+
```
33+
34+
1835
This generator creates TypeScript/JavaScript client that utilizes [axios](https://github.com/axios/axios). The generated Node module can be used in the following environments:
1936

2037
Environment

api/transcriptions-api.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ import type { VoiceApiError } from '../models';
3434
export const TranscriptionsApiAxiosParamCreator = function (configuration?: Configuration) {
3535
return {
3636
/**
37-
* Delete the specified transcription that was created on this call via [startTranscription](/docs/voice/bxml/startTranscription). Note: After the deletion is requested and a `204` is returned, the transcription will not be accessible anymore. However, it is not deleted immediately. This deletion process, while transparent and irreversible, can take an additional 24 to 48 hours.
37+
* Delete the specified transcription that was created on this call via [startTranscription](/docs/voice/bxml/startTranscription). Note: After the deletion is requested and a `200` is returned, the transcription will not be accessible anymore. However, it is not deleted immediately. This deletion process, while transparent and irreversible, can take an additional 24 to 48 hours.
3838
* @summary Delete a specific transcription
3939
* @param {string} accountId Your Bandwidth Account ID.
4040
* @param {string} callId Programmable Voice API Call ID.
@@ -178,7 +178,7 @@ export const TranscriptionsApiFp = function(configuration?: Configuration) {
178178
const localVarAxiosParamCreator = TranscriptionsApiAxiosParamCreator(configuration)
179179
return {
180180
/**
181-
* Delete the specified transcription that was created on this call via [startTranscription](/docs/voice/bxml/startTranscription). Note: After the deletion is requested and a `204` is returned, the transcription will not be accessible anymore. However, it is not deleted immediately. This deletion process, while transparent and irreversible, can take an additional 24 to 48 hours.
181+
* Delete the specified transcription that was created on this call via [startTranscription](/docs/voice/bxml/startTranscription). Note: After the deletion is requested and a `200` is returned, the transcription will not be accessible anymore. However, it is not deleted immediately. This deletion process, while transparent and irreversible, can take an additional 24 to 48 hours.
182182
* @summary Delete a specific transcription
183183
* @param {string} accountId Your Bandwidth Account ID.
184184
* @param {string} callId Programmable Voice API Call ID.
@@ -232,7 +232,7 @@ export const TranscriptionsApiFactory = function (configuration?: Configuration,
232232
const localVarFp = TranscriptionsApiFp(configuration)
233233
return {
234234
/**
235-
* Delete the specified transcription that was created on this call via [startTranscription](/docs/voice/bxml/startTranscription). Note: After the deletion is requested and a `204` is returned, the transcription will not be accessible anymore. However, it is not deleted immediately. This deletion process, while transparent and irreversible, can take an additional 24 to 48 hours.
235+
* Delete the specified transcription that was created on this call via [startTranscription](/docs/voice/bxml/startTranscription). Note: After the deletion is requested and a `200` is returned, the transcription will not be accessible anymore. However, it is not deleted immediately. This deletion process, while transparent and irreversible, can take an additional 24 to 48 hours.
236236
* @summary Delete a specific transcription
237237
* @param {string} accountId Your Bandwidth Account ID.
238238
* @param {string} callId Programmable Voice API Call ID.
@@ -277,7 +277,7 @@ export const TranscriptionsApiFactory = function (configuration?: Configuration,
277277
*/
278278
export class TranscriptionsApi extends BaseAPI {
279279
/**
280-
* Delete the specified transcription that was created on this call via [startTranscription](/docs/voice/bxml/startTranscription). Note: After the deletion is requested and a `204` is returned, the transcription will not be accessible anymore. However, it is not deleted immediately. This deletion process, while transparent and irreversible, can take an additional 24 to 48 hours.
280+
* Delete the specified transcription that was created on this call via [startTranscription](/docs/voice/bxml/startTranscription). Note: After the deletion is requested and a `200` is returned, the transcription will not be accessible anymore. However, it is not deleted immediately. This deletion process, while transparent and irreversible, can take an additional 24 to 48 hours.
281281
* @summary Delete a specific transcription
282282
* @param {string} accountId Your Bandwidth Account ID.
283283
* @param {string} callId Programmable Voice API Call ID.

bandwidth.yml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1173,7 +1173,7 @@ paths:
11731173
[startTranscription](/docs/voice/bxml/startTranscription).
11741174
11751175
1176-
Note: After the deletion is requested and a `204` is returned, the
1176+
Note: After the deletion is requested and a `200` is returned, the
11771177
transcription will not be accessible anymore. However, it is not deleted
11781178
immediately. This deletion process, while transparent and irreversible,
11791179
can take an additional 24 to 48 hours.
@@ -1183,7 +1183,7 @@ paths:
11831183
- $ref: '#/components/parameters/callId'
11841184
- $ref: '#/components/parameters/transcriptionId'
11851185
responses:
1186-
'204':
1186+
'200':
11871187
$ref: '#/components/responses/deleteCallTranscriptionResponse'
11881188
'400':
11891189
$ref: '#/components/responses/voiceBadRequestError'
@@ -2496,7 +2496,7 @@ components:
24962496
description: >-
24972497
The phone number that made the call, in E.164 format (e.g.
24982498
+15555555555).
2499-
example: '19195554321'
2499+
example: '+19195554321'
25002500
direction:
25012501
$ref: '#/components/schemas/callDirectionEnum'
25022502
state:
@@ -3265,7 +3265,7 @@ components:
32653265
accountId:
32663266
type: string
32673267
description: The user account associated with the call.
3268-
example: '920012'
3268+
example: '9900000'
32693269
callId:
32703270
type: string
32713271
description: The call id associated with the event.
@@ -4139,7 +4139,7 @@ components:
41394139
accountId:
41404140
type: string
41414141
description: The user account associated with the call.
4142-
example: '920012'
4142+
example: '9900000'
41434143
applicationId:
41444144
type: string
41454145
description: The id of the application associated with the call.
@@ -4240,7 +4240,7 @@ components:
42404240
description: >-
42414241
The phone number used as the to field of the B-leg call, in E.164 format
42424242
(e.g. +15555555555).
4243-
example: +15555555555)
4243+
example: "+15555555555"
42444244
mediaUrl:
42454245
nullable: true
42464246
type: string
@@ -4451,7 +4451,7 @@ components:
44514451
messageId:
44524452
type: string
44534453
description: Messaging API Message ID.
4454-
example: 9e0df4ca-b18d-40d7-a59f-82fcdf5ae8e6
4454+
example: 1589228074636lm4k2je7j7jklbn2
44554455
verifyCodeRequest:
44564456
type: object
44574457
properties:
@@ -5787,6 +5787,7 @@ components:
57875787
answerMethod: POST
57885788
answerUrl: https://myServer.example/bandwidth/webhooks/answer
57895789
answerFallbackMethod: POST
5790+
answerFallbackUrl: "https://myServer.example/bandwidth/webhooks/answerFallback"
57905791
disconnectMethod: POST
57915792
disconnectUrl: https://myServer.example/bandwidth/webhooks/disconnect
57925793
username: mySecretUsername

custom_templates/README.mustache

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,37 @@
11
## {{npmName}}
22

3-
[![Tests](https://github.com/Bandwidth/node-sdk/actions/workflows/test-nightly.yml/badge.svg)](https://github.com/Bandwidth/node-sdk/actions/workflows/test-nightly.yml)
3+
[![Tests](https://github.com/Bandwidth/node-sdk/actions/workflows/deploy.yml/badge.svg)](https://github.com/Bandwidth/node-sdk/actions/workflows/deploy.yml)
44

55
### Test Matrix
66
| **OS** | **Node** |
77
|:---:|:---:|
8-
| Windows 2019 | 16, 18, 20, 22 |
9-
| Windows 2022 | 16, 18, 20, 22 |
10-
| Ubuntu 20.04 | 16, 18, 20, 22 |
11-
| Ubuntu 22.04 | 16, 18, 20, 22 |
8+
| Windows 2019 | 18, 20, 22 |
9+
| Windows 2022 | 18, 20, 22 |
10+
| Ubuntu 20.04 | 18, 20, 22 |
11+
| Ubuntu 22.04 | 18, 20, 22 |
1212

1313
#### Available on NPM
1414
```
1515
npm install {{npmName}}
1616
```
1717

18+
19+
#### To Run Unit Tests Locally
20+
21+
1. Install Prism
22+
```bash
23+
npm install -g @stoplight/prism-cli
24+
```
25+
2. Start Prism Mock Server with the OpenAPI Spec
26+
```bash
27+
prism mock bandwidth.yml
28+
```
29+
3. Run Tests
30+
```bash
31+
npm run test-unit
32+
```
33+
34+
1835
This generator creates TypeScript/JavaScript client that utilizes [axios](https://github.com/axios/axios). The generated Node module can be used in the following environments:
1936

2037
Environment

custom_templates/package.mustache

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,10 @@
3333
"xmlbuilder2": "^3.1.1"
3434
},
3535
"devDependencies": {
36-
"@types/node": "^12.11.5",
3736
"@types/jest": "^29.5.12",
37+
"@types/node": "^12.11.5",
3838
"jest": "^29.7.0",
39+
"jest-extended": "^4.0.2",
3940
"ts-jest": "^29.1.1",
4041
"typescript": "^5.0"
4142
}{{#npmRepository}},{{/npmRepository}}

custom_templates/tsconfig.mustache

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,6 @@
2323
"dist",
2424
"tests",
2525
"node_modules"
26-
]
26+
],
27+
"include": ["global.d.ts"]
2728
}

global.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
import 'jest-extended';

0 commit comments

Comments
 (0)