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) })
it('should handle insert error', async () => { const expectedResult = 'Invalid team specified'; await request(server) .post('/') .expect(400) .expect((response) => { assert.ok(response.text.includes(expectedResult)); }); });
test(`order support object format`, async () => { const query = { measures: ['Foo.bar'], order: { 'Foo.bar': 'asc', }, }; const res = await request(app) .get(`/cubejs-api/v1/load?query=${JSON.stringify(query)}`) .set('Authorization', 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.e30.t-IDcSemACt8x4iTMCda8Yhe3iZaWbvV5XKSTbuAn0M') .expect(200); expect(res.body.query.order).toStrictEqual([{ id: 'Foo.bar', desc: false }]); });
test(`date range padding`, async () => { const res = await request(app) .get( '/cubejs-api/v1/load?query={"measures":["Foo.bar"],"timeDimensions":[{"dimension":"Foo.time","granularity":"hour","dateRange":["2020-01-01","2020-01-01"]}]}' ) .set('Authorization', 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.e30.t-IDcSemACt8x4iTMCda8Yhe3iZaWbvV5XKSTbuAn0M') .expect(200); console.log(res.body); expect(res.body.query.timeDimensions[0].dateRange).toStrictEqual([ '2020-01-01T00:00:00.000', '2020-01-01T23:59:59.999', ]); });
test(`passes correct token`, async () => { const res = await request(app) .get('/cubejs-api/v1/load?query={}') .set('Authorization', 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.e30.t-IDcSemACt8x4iTMCda8Yhe3iZaWbvV5XKSTbuAn0M') .expect(400); expect(res.body && res.body.error).toStrictEqual( 'Query should contain either measures, dimensions or timeDimensions with granularities in order to be valid' ); });
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) })
test(`null filter values`, async () => { const res = await request(app) .get( '/cubejs-api/v1/load?query={"measures":["Foo.bar"],"filters":[{"dimension":"Foo.id","operator":"equals","values":[null]}]}' ) .set('Authorization', 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.e30.t-IDcSemACt8x4iTMCda8Yhe3iZaWbvV5XKSTbuAn0M') .expect(200); console.log(res.body); expect(res.body && res.body.data).toStrictEqual([{ 'Foo.bar': 42 }]); });