salix/modules/client/back/methods/client/specs/hasCustomerRole.spec.js

60 lines
1.7 KiB
JavaScript

const app = require('vn-loopback/server/server');
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 done.fail(error);
expect(result).toEqual(jasmine.objectContaining({isCustomer: 1}));
done();
};
app.models.Client.hasCustomerRole(id, params, callback);
});
it('should call the hasCustomerRole() method with a non customer id', done => {
let id = 8;
let params = {};
let callback = (error, result) => {
if (error) return done.fail(error);
expect(result).toEqual(jasmine.objectContaining({isCustomer: 0}));
done();
};
app.models.Client.hasCustomerRole(id, params, callback);
});
it('should call the hasCustomerRole() method with an unreal id', done => {
let id = 999;
let params = {};
let callback = (error, result) => {
if (error) return done.fail(error);
expect(result).toEqual(jasmine.objectContaining({isCustomer: 0}));
done();
};
app.models.Client.hasCustomerRole(id, params, callback);
});
it('should call the hasCustomerRole() method with an invalid id', done => {
let id = 'WRONG!';
let params = {};
let callback = (error, result) => {
if (error) return done.fail(error);
expect(result).toEqual(jasmine.objectContaining({isCustomer: 0}));
done();
};
app.models.Client.hasCustomerRole(id, params, callback);
});
});