Skip to content

Instantly share code, notes, and snippets.

@reke592
Created November 7, 2021 13:58
Show Gist options
  • Save reke592/d4ffc15966c8c56e9c04f718a2d20264 to your computer and use it in GitHub Desktop.
Save reke592/d4ffc15966c8c56e9c04f718a2d20264 to your computer and use it in GitHub Desktop.
Sample dropdown option test case using supertest
const request = require('supertest');
const { app } = require('../server');
describe('Form input options', () => {
it('GET /option/regions --> array public list regions', () => {
return request(app)
.get('/option/regions')
.expect('Content-Type', /json/)
.expect(200)
.then(response => {
return expect(response.body).toEqual(expect.arrayContaining([
expect.objectContaining({
name: expect.any(String)
})
]))
});
});
it('GET /option/genders --> 200 array public list genders', () => {
return request(app)
.get('/option/genders')
.expect('Content-Type', /json/)
.expect(200)
.then(response => {
return expect(response.body).toEqual(expect.arrayContaining([
expect.objectContaining({
id: expect.any(Number),
name: expect.any(String)
})
]))
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment