Additional invalid tests cases

Use it.each to run the same test with various invalid test data
This commit is contained in:
Josh Betz 2021-08-26 13:42:00 -05:00
parent dc5e8af63e
commit 7920bbe1c0
1 changed files with 10 additions and 3 deletions

View File

@ -31,12 +31,19 @@ const runTelemetryAPITest = () => {
.create();
} );
it( 'errors for missing fields', async () => {
await client
.post( `/wc/v3/telemetry` )
it.each([
null,
{},
{ platform: 'ios' },
{ version: '1.1' },
])( 'errors for invalid request body - %p', async data => {
const response = await client
.post( `/wc/v3/telemetry`, data )
.catch( err => {
expect( err.statusCode ).toBe( 400 );
} );
expect( response ).toBeUndefined();
} );
it( 'returns 200 with correct fields', async () => {