2018-08-13 11:11:37 +00:00
|
|
|
const app = require(`${servicesDir}/client/server/server`);
|
|
|
|
const catchErrors = require(`${servicesDir}/utils/jasmineHelpers`).catchErrors;
|
2018-01-26 08:00:16 +00:00
|
|
|
|
2018-01-31 11:17:17 +00:00
|
|
|
describe('Client hasCustomerRole', () => {
|
|
|
|
it('should call the hasCustomerRole() method with a customer id', done => {
|
2018-03-08 11:23:51 +00:00
|
|
|
let id = 101;
|
2018-01-26 08:00:16 +00:00
|
|
|
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-26 08:00:16 +00:00
|
|
|
});
|
|
|
|
|
2018-01-31 11:17:17 +00:00
|
|
|
it('should call the hasCustomerRole() method with a non customer id', done => {
|
2018-01-26 08:00:16 +00:00
|
|
|
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-26 08:00:16 +00:00
|
|
|
});
|
|
|
|
|
2018-01-31 11:17:17 +00:00
|
|
|
it('should call the hasCustomerRole() method with an unreal id', done => {
|
2018-01-26 08:00:16 +00:00
|
|
|
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-26 08:00:16 +00:00
|
|
|
});
|
|
|
|
|
2018-01-31 11:17:17 +00:00
|
|
|
it('should call the hasCustomerRole() method with an invalid id', done => {
|
2018-01-26 08:00:16 +00:00
|
|
|
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);
|
2018-01-26 08:00:16 +00:00
|
|
|
});
|
|
|
|
});
|