UNPKG

cs-mpx-dataservice

Version:

MPX Dataservices

96 lines (78 loc) 2.85 kB
/** * Created by paul.rangel on 4/29/15. */ var expect = require("chai").expect; var should = require("should"); var DataService = require("../lib/dataService"); var endpoints = require("./data/endpoints"); var accountToken = require("./data/accountToken"); var categoryId = "http://data.media.sandbox.theplatform.com/media/data/Category/31507363"; var account = "http://stg-admin.access.auth.theplatform.com/data/Account/1454466589" DataService.init(account, accountToken.token); describe("getFeed()", function() { it("Should return feedData with more than 1 entries", function (done) { DataService.getFeed(endpoints.Category).then(function(data) { console.log(data); should(data.entries.length).be.above(1); done(); }, function(error) { console.error("error: ", error); done(); }) }); it("Should have keys id and guid if fields=id,guid", function (done) { DataService.getFeed(endpoints.Category, {"fields":"id,guid"}).then(function(data) { //console.log("data: ", data); var entry = data.entries[0]; entry.should.have.keys(["id","guid"]); done(); }, function(error) { console.error("error: ", error); done(); }) }); }); describe("getAll()", function() { it("Should return feedData with the entries length equal to the entryCount", function (done) { DataService.getAll(endpoints.Category).then(function(data) { (data).should.be.Array; (data.length).should.be.above(80); done(); }, function(error) { console.error("error: ", error); done(); }) }); }); describe("getAllWithRange()", function() { it("Should return feedData with the entries length equal the range length", function (done) { DataService.getAllWithRange(endpoints.Category, "1-20").then(function(data) { console.log(data); (data.length).should.be.equal(20); done(); }, function(error) { console.error("error: ", error); done(); }) }); }); describe("getCount()", function() { it("Should return count equal to 81", function (done) { DataService.getCount(endpoints.Category).then(function(data) { //console.log(data); (data).should.be.equal(81); done(); }, function(error) { console.error("error: ", error); done(); }) }); }); describe("getById", function() { it("Should return data with a matching ID", function(done) { DataService.getById(endpoints.Category, categoryId).then(function(data) { (data.id).should.equal(categoryId); done(); }) }); });