salix/services/loopback/common/methods/client/specs/hasCustomerRole.spec.js

61 lines
1.8 KiB
JavaScript
Raw Normal View History

const app = require(`${servicesDir}/client/server/server`);
const catchErrors = require(`${servicesDir}/utils/jasmineHelpers`).catchErrors;
2018-01-31 11:17:17 +00:00
describe('Client hasCustomerRole', () => {
it('should call the hasCustomerRole() method with a customer id', done => {
let id = 101;
let params = {};
let callback = (error, result) => {
if (error) return catchErrors(done)(error);
expect(result).toEqual(jasmine.objectContaining({isCustomer: 1}));
done();
};
2018-01-31 11:17:17 +00:00
app.models.Client.hasCustomerRole(id, params, callback);
});
2018-01-31 11:17:17 +00:00
it('should call the hasCustomerRole() method with a non customer id', done => {
let id = 8;
let params = {};
let callback = (error, result) => {
if (error) return catchErrors(done)(error);
expect(result).toEqual(jasmine.objectContaining({isCustomer: 0}));
done();
};
2018-01-31 11:17:17 +00:00
app.models.Client.hasCustomerRole(id, params, callback);
});
2018-01-31 11:17:17 +00:00
it('should call the hasCustomerRole() method with an unreal id', done => {
let id = 999;
let params = {};
let callback = (error, result) => {
if (error) return catchErrors(done)(error);
expect(result).toEqual(jasmine.objectContaining({isCustomer: 0}));
done();
};
2018-01-31 11:17:17 +00:00
app.models.Client.hasCustomerRole(id, params, callback);
});
2018-01-31 11:17:17 +00:00
it('should call the hasCustomerRole() method with an invalid id', done => {
let id = 'WRONG!';
let params = {};
let callback = (error, result) => {
if (error) return catchErrors(done)(error);
expect(result).toEqual(jasmine.objectContaining({isCustomer: 0}));
done();
};
2018-01-31 11:17:17 +00:00
app.models.Client.hasCustomerRole(id, params, callback);
});
});