it("GET " + apiPrefix + "offices/ugroupby?_fields= should PASS", function( done ) { //post to an url with data agent .get(apiPrefix + "offices/ugroupby?_fields=") //enter url .expect(400) //200 for success 4xx for failure .end(function(err, res) { // Handle /api/v error if (err) { return done(err); } Object.keys(res.body).length.should.be.equals(1); return done(); }); });
it( "GET " + apiPrefix + "offices?_fields=officeCode,ity should PASS", function(done) { //http get an url agent .get(apiPrefix + "offices?_fields=officeCode,ity") // api url .expect(200) // 2xx for success and 4xx for failure .end(function(err, res) { // Handle /api/offices/1/employees error if (err) { return done(err); } //validate resonse res.body.should.be.instanceOf(Array); // ity in _fields is an in valid column and it should be ignored Object.keys(res.body[0]).length.should.be.equal(1); return done(); }); } );
it( "GET " + apiPrefix + "offices/ugroupby?_fields=country,city,state should PASS", function(done) { //post to an url with data agent .get(apiPrefix + "offices/ugroupby?_fields=country,city,state") //enter url .expect(200) //200 for success 4xx for failure .end(function(err, res) { // Handle /api/v error if (err) { return done(err); } //validate response //res.body.length.should.be.equals(3) Object.keys(res.body).length.should.be.equals(3); res.body["country"].length.should.be.equals(5); res.body["city"].length.should.be.equals(7); res.body["state"].length.should.be.equals(5); return done(); }); } );
it( "GET " + apiPrefix + "orders/aggregate?_fields=orderNumber,customerNumber should PASS", function(done) { //post to an url with data agent .get(apiPrefix + "orders/aggregate?_fields=orderNumber,customerNumber") //enter url .expect(200) //200 for success 4xx for failure .end(function(err, res) { // Handle /api/v error if (err) { return done(err); } //validate response res.body[0]["min_of_orderNumber"].should.be.equals(10100); res.body[0]["max_of_orderNumber"].should.be.equals(10425); res.body[0]["sum_of_orderNumber"].should.be.equals(3345575); Object.keys(res.body[0]).length.should.be.equals(12); return done(); }); } );
describe('#enable and disable', function () { it('should play the role of enable and disable', function () { let key = 'some enable key'; app.enabled(key).should.be.false; app.disabled(key).should.be.true; app.enable(key); app.enabled(key).should.be.true; app.disabled(key).should.be.false; app.disable(key); app.enabled(key).should.be.false; app.disabled(key).should.be.true; }); });
it( "GET " + apiPrefix + "offices/ugroupby?_fields=country should PASS", function(done) { //post to an url with data agent .get(apiPrefix + "offices/ugroupby?_fields=country") //enter url .expect(200) //200 for success 4xx for failure .end(function(err, res) { // Handle /api/v error if (err) { return done(err); } //validate response Object.keys(res.body).length.should.be.equals(1); res.body["country"].length.should.be.equals(5); return done(); }); } );
it( "GET " + apiPrefix + "offices/ugroupby?_fields=country,city should PASS", function(done) { //post to an url with data agent .get(apiPrefix + "offices/ugroupby?_fields=country,city") //enter url .expect(200) //200 for success 4xx for failure .end(function(err, res) { // Handle /api/v error if (err) { return done(err); } //validate response Object.keys(res.body).length.should.be.equals(2); res.body["country"].length.should.be.equals(5); res.body["city"].length.should.be.equals(7); return done(); }); } );
it( "GET " + apiPrefix + "offices?_fields=officeCode,city should PASS", function(done) { //http get an url agent .get(apiPrefix + "offices?_fields=officeCode,city") // api url .expect(200) // 2xx for success and 4xx for failure .end(function(err, res) { // Handle /api/offices/1/employees error if (err) { return done(err); } //validate resonse res.body.should.be.instanceOf(Array); Object.keys(res.body[0]).length.should.be.equal(2); return done(); }); } );
it( "GET " + apiPrefix + "offices?_fields=-territory,-addressLine2,-state should PASS", function(done) { //http get an url agent .get(apiPrefix + "offices?_fields=-territory,-addressLine2,-state") // api url .expect(200) // 2xx for success and 4xx for failure .end(function(err, res) { // Handle /api/offices/1/employees error if (err) { return done(err); } //validate resonse res.body.should.be.instanceOf(Array); Object.keys(res.body[0]).length.should.be.equal(6); return done(); }); } );
it( "GET " + apiPrefix + "offices?_fields=-territory,-addressLine2,-state,-tate should PASS", function(done) { //http get an url agent .get(apiPrefix + "offices?_fields=-territory,-addressLine2,-state") // api url .expect(200) // 2xx for success and 4xx for failure .end(function(err, res) { // Handle /api/offices/1/employees error if (err) { return done(err); } //validate resonse res.body.should.be.instanceOf(Array); // tate is an invalid column but still it should query right number of columns Object.keys(res.body[0]).length.should.be.equal(6); return done(); }); } );
it( "GET " + apiPrefix + "xjoin?_join=pl.productlines,_j,pr.products&_on1=(pl.productline,eq,pr.productline)&_fields=pl.productline,pr.productName should PASS", function(done) { //post to an url with data agent .get( apiPrefix + "xjoin?_join=pl.productlines,_j,pr.products&_on1=(pl.productline,eq,pr.productline)&_fields=pl.productline,pr.productName" ) //enter url .expect(200) //200 for success 4xx for failure .end(function(err, res) { // Handle /api/v error if (err) { return done(err); } //validate response Object.keys(res.body[0]).length.should.be.equals(2); res.body.length.should.be.equals(20); return done(); }); } );
it( "GET " + apiPrefix + "xjoin?_join=pl.productlines,_j,pr.products&_on1=(pl.productline,eq,pr.productline)&_fields=pl.productline,pr.productName&_size=2 should PASS", function(done) { //post to an url with data agent .get( apiPrefix + "xjoin?_join=pl.productlines,_j,pr.products&_on1=(pl.productline,eq,pr.productline)&_fields=pl.productline,pr.productName&_size=2" ) //enter url .expect(200) //200 for success 4xx for failure .end(function(err, res) { // Handle /api/v error if (err) { return done(err); } //validate response Object.keys(res.body[0]).length.should.be.equals(2); res.body.length.should.be.equals(2); return done(); }); } );
describe('#enable and disable', function () { it('should play the role of enable and disable', function () { let key = 'some enable key'; app.enabled(key).should.be.false; app.disabled(key).should.be.true; app.enable(key); app.enabled(key).should.be.true; app.disabled(key).should.be.false; app.disable(key); app.enabled(key).should.be.false; app.disabled(key).should.be.true; }); });