Last active
September 7, 2020 14:01
-
-
Save JasonMadeSomething/03596d490f707bd9288146de4b9dec05 to your computer and use it in GitHub Desktop.
dynamic test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const endpoints = [ | |
{ | |
category: "appointment", | |
apiEndpoint: "appointment/activesessiontimes", | |
name: "activeSessionTimes" | |
}, | |
{ | |
category: "appointment", | |
apiEndpoint: "appointment/addons", | |
name: "appointmentAddOns" | |
}, | |
{ | |
category: "appointment", | |
apiEndpoint: "appointment/availabledates", | |
name: "appointmentAvailableDates" | |
}, | |
{ | |
category: "appointment", | |
apiEndpoint: "appointment/appointmentoptions", | |
name: "appointmentOptions" | |
}, | |
{ | |
category: "appointment", | |
apiEndpoint: "appointment/bookableitems", | |
name: "bookableItems" | |
}, | |
{ | |
category: "appointment", | |
apiEndpoint: "appointment/scheduleitems", | |
name: "scheduleItems" | |
}, | |
{ | |
category: "appointment", | |
apiEndpoint: "appointment/staffappointments", | |
name: "staffAppointments" | |
}, | |
{ | |
category: "appointment", | |
apiEndpoint: "appointment/addappointment", | |
name: "addAppointment" | |
}, | |
{ | |
category: "appointment", | |
apiEndpoint: "appointment/addappointmentaddon", | |
name: "addAppointmentAddOn" | |
}, | |
{ | |
category: "appointment", | |
apiEndpoint: "appointment/updateappointment", | |
name: "updateAppointment" | |
}, | |
{ | |
category: "appointment", | |
apiEndpoint: "appointment/deleteappointmentaddon", | |
name: "deleteAppointmentAddOn" | |
}, | |
{ | |
category: "class", | |
apiEndpoint: "class/classes", | |
name: "classes" | |
}, | |
{ | |
category: "class", | |
apiEndpoint: "class/classdescriptions", | |
name: "classDescriptions" | |
}, | |
{ | |
category: "class", | |
apiEndpoint: "class/classschedules", | |
name: "classSchedules" | |
}, | |
{ | |
category: "class", | |
apiEndpoint: "class/classvisits", | |
name: "classVisits" | |
}, | |
{ | |
category: "class", | |
apiEndpoint: "class/waitlistentries", | |
name: "waitListEntries" | |
}, | |
{ | |
category: "class", | |
apiEndpoint: "class/addclienttoclass", | |
name: "addClientToClass" | |
}, | |
{ | |
category: "class", | |
apiEndpoint: "class/removeclientfromclass", | |
name: "removeClientFromClass" | |
}, | |
{ | |
category: "class", | |
apiEndpoint: "class/removefromwaitlist", | |
name: "removeFromWaitlist" | |
}, | |
{ | |
category: "class", | |
apiEndpoint: "class/substituteclassteacher", | |
name: "substituteClassTeacher" | |
}, | |
{ | |
category: "client", | |
apiEndpoint: "client/activeclientmemberships", | |
name: "activeClientMemberships" | |
}, | |
{ | |
category: "client", | |
apiEndpoint: "client/clientaccountbalances", | |
name: "clientAccountBalances" | |
}, | |
{ | |
category: "client", | |
apiEndpoint: "client/contactlogs", | |
name: "contactLogs" | |
}, | |
{ | |
category: "client", | |
apiEndpoint: "client/clientcontracts", | |
name: "clientContracts" | |
}, | |
{ | |
category: "client", | |
apiEndpoint: "client/clientduplicates", | |
name: "clientDuplicates" | |
}, | |
{ | |
category: "client", | |
apiEndpoint: "client/clientformulanotes", | |
name: "clientFormulaNotes" | |
}, | |
{ | |
category: "client", | |
apiEndpoint: "client/clientindexes", | |
name: "clientIndexes" | |
}, | |
{ | |
category: "client", | |
apiEndpoint: "client/clientpurchases", | |
name: "clientPurchases" | |
}, | |
{ | |
category: "client", | |
apiEndpoint: "client/clientreferraltypes", | |
name: "clientReferralTypes" | |
}, | |
{ | |
category: "client", | |
apiEndpoint: "client/clients", | |
name: "clients" | |
}, | |
{ | |
category: "client", | |
apiEndpoint: "client/clientservices", | |
name: "clientServices" | |
}, | |
{ | |
category: "client", | |
apiEndpoint: "client/clientvisits", | |
name: "clientVisits" | |
}, | |
{ | |
category: "client", | |
apiEndpoint: "client/customclientfields", | |
name: "customClientFields" | |
}, | |
{ | |
category: "client", | |
apiEndpoint: "client/crossregionalclientassociations", | |
name: "crossRegionalClientAssociations" | |
}, | |
{ | |
category: "client", | |
apiEndpoint: "client/requiredclientfields", | |
name: "requiredClientFields" | |
}, | |
{ | |
category: "client", | |
apiEndpoint: "client/addarrival", | |
name: "addArrival" | |
}, | |
{ | |
category: "client", | |
apiEndpoint: "client/addclient", | |
name: "addClient" | |
}, | |
{ | |
category: "client", | |
apiEndpoint: "client/addclientdirectdebitinfo", | |
name: "addClientDirectDebitInfo" | |
}, | |
{ | |
category: "client", | |
apiEndpoint: "client/addcontactlog", | |
name: "addContactLog" | |
}, | |
{ | |
category: "client", | |
apiEndpoint: "client/sendpasswordresetemail", | |
name: "sendPasswordResetEmail" | |
}, | |
{ | |
category: "client", | |
apiEndpoint: "client/updateclient", | |
name: "updateClient" | |
}, | |
{ | |
category: "client", | |
apiEndpoint: "client/updateclientservice", | |
name: "updateclientService" | |
}, | |
{ | |
category: "client", | |
apiEndpoint: "client/updateclientvisit", | |
name: "updateClientVisit" | |
}, | |
{ | |
category: "client", | |
apiEndpoint: "client/updatecontactlog", | |
name: "updateContactLog" | |
}, | |
{ | |
category: "client", | |
apiEndpoint: "client/uploadclientdocument", | |
name: "uploadClientDocument" | |
}, | |
{ | |
category: "client", | |
apiEndpoint: "client/uploadclientphoto", | |
name: "uploadClientPhoto" | |
}, | |
{ | |
category: "client", | |
apiEndpoint: "client/clientdirectdebitinfo", | |
name: "deleteAppointmentAddOn" | |
}, | |
{ | |
category: "enrollment", | |
apiEndpoint: "enrollments/enrollments", | |
name: "enrollments" | |
}, | |
{ | |
category: "enrollment", | |
apiEndpoint: "enrollment/addclienttoenrollment", | |
name: "addClientToEnrollment" | |
}, | |
{ | |
category: "payroll", | |
apiEndpoint: "payroll/commissions", | |
name: "commissions" | |
}, | |
{ | |
category: "payroll", | |
apiEndpoint: "payroll/scheduledserviceearnings", | |
name: "scheduledServiceEarnings" | |
}, | |
{ | |
category: "payroll", | |
apiEndpoint: "payroll/timecards", | |
name: "timeCards" | |
}, | |
{ | |
category: "payroll", | |
apiEndpoint: "payroll/tips", | |
name: "tips" | |
}, | |
{ | |
category: "sale", | |
apiEndpoint: "sale/acceptedcardtypes", | |
name: "acceptedCardTypes" | |
}, | |
{ | |
category: "sale", | |
apiEndpoint: "sale/contracts", | |
name: "contracts" | |
}, | |
{ | |
category: "sale", | |
apiEndpoint: "sale/custompaymentmethods", | |
name: "customPaymentMethods" | |
}, | |
{ | |
category: "sale", | |
apiEndpoint: "sale/giftcardbalance", | |
name: "giftCardBalance" | |
}, | |
{ | |
category: "sale", | |
apiEndpoint: "sale/giftcards", | |
name: "giftCards" | |
}, | |
{ | |
category: "sale", | |
apiEndpoint: "sale/packages", | |
name: "packages" | |
}, | |
{ | |
category: "sale", | |
apiEndpoint: "sale/products", | |
name: "products" | |
}, | |
{ | |
category: "sale", | |
apiEndpoint: "sale/sales", | |
name: "sales" | |
}, | |
{ | |
category: "sale", | |
apiEndpoint: "sale/services", | |
name: "services" | |
}, | |
{ | |
category: "sale", | |
apiEndpoint: "sale/checkoutshoppingcart", | |
name: "checkoutShoppingCart" | |
}, | |
{ | |
category: "sale", | |
apiEndpoint: "sale/purchasegiftcard", | |
name: "purchaseGiftCard" | |
}, | |
{ | |
category: "site", | |
apiEndpoint: "site/genders", | |
name: "genders" | |
}, | |
{ | |
category: "site", | |
apiEndpoint: "site/locations", | |
name: "locations" | |
}, | |
{ | |
category: "site", | |
apiEndpoint: "site/memberships", | |
name: "memberships" | |
}, | |
{ | |
category: "site", | |
apiEndpoint: "site/programs", | |
name: "programs" | |
}, | |
{ | |
category: "site", | |
apiEndpoint: "site/resources", | |
name: "resources" | |
}, | |
{ | |
category: "site", | |
apiEndpoint: "site/sessiontypes", | |
name: "sessionTypes" | |
}, | |
{ | |
category: "site", | |
apiEndpoint: "site/sites", | |
name: "sites" | |
}, | |
{ | |
category: "staff", | |
apiEndpoint: "staff/staff", | |
name: "staff" | |
}, | |
{ | |
category: "staff", | |
apiEndpoint: "staff/staffpermissions", | |
name: "staffPermissions" | |
}, | |
{ | |
category: "usertoken", | |
apiEndpoint: "usertoken/issue", | |
name: "issue" | |
}, | |
] | |
module.exports = endpoints |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const MindBody = require("../lib/mindbody-sdk") | |
const sinon = require("sinon") | |
const expect = require("chai").expect | |
const nock = require("nock") | |
const endpoints = require("./mocks/endpointlist") | |
const categories = [ | |
"appointment", | |
"class", | |
"client", | |
"enrollment", | |
"payroll", | |
"sale", | |
"site", | |
"staff", | |
"usertoken", | |
] | |
const mb = new MindBody({ | |
ApiKey: 'api-key', | |
SiteId: 12345 | |
}) | |
const sandbox = sinon.createSandbox() | |
describe("MindBody Class categories", function () { | |
categories.forEach(function (category) { | |
describe(category + " category return test", function () { | |
beforeEach(function () { | |
nock('https://api.mindbodyonline.com/public/v6') | |
.get(/.*/) | |
.reply(200, {}) | |
.post(/.*/) | |
.reply(200, {}) | |
.delete(/.*/) | |
.reply(200, {}) | |
sandbox.spy(mb, "request") | |
}) | |
afterEach(function () { | |
sandbox.restore() | |
}) | |
const currentEndpoints = endpoints.filter(function (endpoint) { return endpoint.category === category }) | |
currentEndpoints.forEach(function (endpoint) { | |
const basicRequestDetails = { ext: "/public/v6", subd: "api.", url: endpoint.apiEndpoint, verb: "GET" } | |
it(`${endpoint.name} should return once when invoked`, async function () { | |
const reply = await mb[category][endpoint.name]() | |
sinon.assert.calledOnce(mb.request) | |
sinon.assert.calledWith(mb.request, basicRequestDetails) | |
expect(reply).to.exist | |
}) | |
}) | |
}) | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment