supertest('https://192.168.99.100:8080') .post('/notification/sendEmail') .send({payload}) .end((err, res) => { if (err) { reject(new Error('An error occured with the payment service, err: ' + err)) } resolve(res.body) })
describe('PATCH /api/v1/calendar/:calendar_selector', () => { it('should update a calendar', async () => { await authenticatedRequest .patch('/api/v1/calendar/test-calendar') .send({ name: 'new name', }) .expect('Content-Type', /json/) .expect(200) .then((res) => { expect(res.body).to.have.property('name', 'new name'); }); }); });
describe('POST /api/v1/user/:user_selector/location', () => { it('should save user location', async () => { await authenticatedRequest .post('/api/v1/user/john/location') .send({ latitude: 12, longitude: 12, }) .expect('Content-Type', /json/) .expect(201) .then((res) => { expect(res.body).to.have.property('latitude', 12); expect(res.body).to.have.property('longitude', 12); expect(res.body).to.have.property('user_id', '0cd30aef-9c4e-4a23-88e3-3547971296e5'); }); }); });
supertest('https://192.168.99.100:8080') .post('/payment/makePurchase') .send({paymentOrder}) .end((err, res) => { if (err) { reject(new Error('An error occured with the payment service, err: ' + err)) } resolve(res.body.paid) })
describe('POST /api/v1/camera/:camera_selector/image', () => { it('should set image', async () => { await authenticatedRequest .post('/api/v1/camera/test-camera/image') .send({ image: RANDOM_IMAGE, }) .expect('Content-Type', /json/) .expect(201) .then((res) => { expect(res.body).to.deep.equal({ success: true, }); }); }); });
describe('PATCH /api/v1/room/:room_selector', () => { it('should update a room', async () => { await authenticatedRequest .patch('/api/v1/room/test-room') .send({ name: 'new name', }) .expect('Content-Type', /json/) .expect(200) .then((res) => { expect(res.body).to.have.property('name', 'new name'); expect(res.body).to.have.property('selector', 'test-room'); }); }); });
describe('POST /api/v1/service/:service_name/variable/:variable_name', () => { it('should set a variable for a service', async () => { await authenticatedRequest .post('/api/v1/service/test-service/variable/SECURE_VARIABLE') .send({ value: 'NEW_SERVICE_DATA', }) .expect('Content-Type', /json/) .expect(200) .then((res) => { expect(res.body).to.have.property('value', 'NEW_SERVICE_DATA'); }); }); });
describe('POST /api/v1/house/:house_selector/room', () => { it('should create room', async () => { await authenticatedRequest .post('/api/v1/house/test-house/room') .send({ name: 'my room', }) .expect('Content-Type', /json/) .expect(201) .then((res) => { expect(res.body).to.have.property('name', 'my room'); expect(res.body).to.have.property('selector', 'my-room'); }); }); });
describe('PATCH /api/v1/scene/:scene_selector', () => { it('should update scene', async () => { await authenticatedRequest .patch('/api/v1/scene/test-scene') .send({ name: 'New name', }) .expect('Content-Type', /json/) .expect(200) .then((res) => { expect(res.body).to.have.property('name', 'New name'); }); }); });
describe('PATCH /api/v1/house/test-house', () => { it('should update a house', async () => { await authenticatedRequest .patch('/api/v1/house/test-house') .send({ name: 'NEW NAME', }) .expect('Content-Type', /json/) .expect(200) .then((res) => { expect(res.body).to.have.property('name', 'NEW NAME'); }); }); });
describe('PATCH /api/v1/area/:area_selector', () => { it('should update a area', async () => { await authenticatedRequest .patch('/api/v1/area/test-area') .send({ name: 'new name', }) .expect('Content-Type', /json/) .expect(200) .then((res) => { expect(res.body).to.have.property('name', 'new name'); }); }); });
describe('PATCH /api/v1/calendar/event/:calendar_event_selector', () => { it('should update a calendar event', async () => { await authenticatedRequest .patch('/api/v1/calendar/event/test-calendar-event') .send({ name: 'new name', }) .expect('Content-Type', /json/) .expect(200) .then((res) => { expect(res.body).to.have.property('name', 'new name'); }); }); });
describe('POST /api/v1/calendar/:calendar_selector/event', () => { it('should create an event', async () => { await authenticatedRequest .post('/api/v1/calendar/test-calendar/event') .send({ name: 'a new event', start: '2019-02-12 07:49:07.556', }) .expect('Content-Type', /json/) .expect(201) .then((res) => { expect(res.body).to.have.property('name', 'a new event'); }); }); });
describe('POST /api/v1/house', () => { it('should create house', async () => { await authenticatedRequest .post('/api/v1/house') .send({ name: 'my house', }) .expect('Content-Type', /json/) .expect(201) .then((res) => { expect(res.body).to.have.property('name', 'my house'); expect(res.body).to.have.property('selector', 'my-house'); }); }); });
describe('POST /api/v1/calendar', () => { it('should create calendar', async () => { await authenticatedRequest .post('/api/v1/calendar') .send({ name: 'my calendar', description: 'This is a great calendar', }) .expect('Content-Type', /json/) .expect(201) .then((res) => { expect(res.body).to.have.property('name', 'my calendar'); expect(res.body).to.have.property('description', 'This is a great calendar'); }); }); });