jasmine ESLint plugging added to dev dependencies and refactor on all specs according to eslint rules.
This commit is contained in:
parent
e20dd82928
commit
9ed9e13b54
|
@ -1,5 +1,9 @@
|
|||
extends: [eslint:recommended, google]
|
||||
extends: [eslint:recommended, google, plugin:jasmine/recommended]
|
||||
installedESLint: true
|
||||
plugins:
|
||||
- jasmine
|
||||
env:
|
||||
jasmine: true
|
||||
rules:
|
||||
indent: [error, 4]
|
||||
require-jsdoc: 0
|
||||
|
|
|
@ -17,6 +17,7 @@ describe('Client', () => {
|
|||
|
||||
it('should define and set address property', () => {
|
||||
let controller = $componentController('vnAddressCreate', {$state: $state});
|
||||
|
||||
expect(controller.address.clientFk).toBe(1234);
|
||||
expect(controller.address.enabled).toBe(true);
|
||||
});
|
||||
|
|
|
@ -17,6 +17,7 @@ describe('Client', () => {
|
|||
|
||||
it('should define and set address property', () => {
|
||||
let controller = $componentController('vnAddressEdit', {$state: $state});
|
||||
|
||||
expect(controller.address.id).toBe(1234);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -33,6 +33,7 @@ describe('Client', () => {
|
|||
};
|
||||
controller.billData = {};
|
||||
controller.copyData(controller.client);
|
||||
|
||||
expect(controller.billData).toEqual(controller.client);
|
||||
});
|
||||
});
|
||||
|
@ -43,8 +44,8 @@ describe('Client', () => {
|
|||
spyOn(controller, 'checkPaymentChanges');
|
||||
controller.submit()
|
||||
.then(() => {
|
||||
expect(controller.$.watcher.submit).toHaveBeenCalled();
|
||||
expect(controller.checkPaymentChanges).toHaveBeenCalled();
|
||||
expect(controller.$.watcher.submit).toHaveBeenCalledWith();
|
||||
expect(controller.checkPaymentChanges).toHaveBeenCalledWith();
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
@ -56,6 +57,7 @@ describe('Client', () => {
|
|||
controller.billData = {marvelHero: 'Silver Surfer'};
|
||||
controller.client = {marvelHero: 'Silver Surfer'};
|
||||
controller.checkPaymentChanges();
|
||||
|
||||
expect(controller.$.sendMail.show).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
|
@ -64,7 +66,8 @@ describe('Client', () => {
|
|||
controller.billData = {marvelHero: 'Silver Surfer'};
|
||||
controller.client = {marvelHero: 'Spider-Man'};
|
||||
controller.checkPaymentChanges();
|
||||
expect(controller.$.sendMail.show).toHaveBeenCalled();
|
||||
|
||||
expect(controller.$.sendMail.show).toHaveBeenCalledWith();
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@ describe('Client', () => {
|
|||
|
||||
it('should define and set client property to null in the module instance', () => {
|
||||
let controller = $componentController('vnClientCard', {$scope: $scope});
|
||||
|
||||
expect(controller.client).toBeDefined();
|
||||
expect(controller.client).toBe(null);
|
||||
});
|
||||
|
|
|
@ -27,6 +27,7 @@ describe('Client', () => {
|
|||
|
||||
it('should define and set scope, state and client properties', () => {
|
||||
let controller = $componentController('vnClientCreate', {$scope: $scope});
|
||||
|
||||
expect(controller.$).toBe($scope);
|
||||
expect(controller.$state).toBe($state);
|
||||
expect(controller.client.active).toBe(true);
|
||||
|
@ -37,6 +38,7 @@ describe('Client', () => {
|
|||
let controller = $componentController('vnClientCreate', {$scope: $scope});
|
||||
spyOn($state, 'go');
|
||||
controller.onSubmit();
|
||||
|
||||
expect(controller.$state.go).toHaveBeenCalledWith('clientCard.basicData', {id: '1234'});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -18,10 +18,13 @@ describe('Client', () => {
|
|||
it('should check if active is defined and diferent from the new value', () => {
|
||||
let controller = $componentController('vnDescriptor', {$scope: $scope});
|
||||
controller.client = {id: 1};
|
||||
|
||||
expect(controller._active).toBe(undefined);
|
||||
controller.active = false;
|
||||
|
||||
expect(controller._active).toBe(false);
|
||||
controller.active = true;
|
||||
|
||||
expect(controller._active).toBe(true);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -14,6 +14,7 @@ describe('Client', () => {
|
|||
|
||||
it('should define and set model property as an empty object', () => {
|
||||
let controller = $componentController('vnClientIndex');
|
||||
|
||||
expect(controller.model).toEqual({});
|
||||
});
|
||||
|
||||
|
@ -28,6 +29,7 @@ describe('Client', () => {
|
|||
}
|
||||
};
|
||||
controller.search(index);
|
||||
|
||||
expect(index.filter.search).toBe('batman');
|
||||
});
|
||||
});
|
||||
|
|
|
@ -17,6 +17,7 @@ describe('Client', () => {
|
|||
|
||||
it('should define clientFk using $state.params.id', () => {
|
||||
let controller = $componentController('vnNoteCreate', {$state: $state});
|
||||
|
||||
expect(controller.note.clientFk).toBe(1234);
|
||||
expect(controller.note.client).toBe(undefined);
|
||||
});
|
||||
|
|
|
@ -24,6 +24,7 @@ describe('Client', () => {
|
|||
};
|
||||
spyOn(controller, 'getObservation').and.returnValue();
|
||||
controller.$onChanges();
|
||||
|
||||
expect(controller.getObservation).toHaveBeenCalledWith(1234);
|
||||
});
|
||||
});
|
||||
|
@ -46,6 +47,7 @@ describe('Client', () => {
|
|||
controller.client = {id: '1234'};
|
||||
spyOn(controller.$state, 'go');
|
||||
controller.newObservation();
|
||||
|
||||
expect(controller.$state.go).toHaveBeenCalledWith('clientCard.notes.create', Object({id: '1234'}));
|
||||
});
|
||||
});
|
||||
|
|
|
@ -21,17 +21,20 @@ describe('Client', () => {
|
|||
spyOn(controller, 'onSubmit');
|
||||
controller.setStorageValue();
|
||||
controller.onSubmit();
|
||||
expect(controller.setStorageValue).toHaveBeenCalled();
|
||||
expect(controller.onSubmit).toHaveBeenCalled();
|
||||
|
||||
expect(controller.setStorageValue).toHaveBeenCalledWith();
|
||||
expect(controller.onSubmit).toHaveBeenCalledWith();
|
||||
});
|
||||
});
|
||||
|
||||
describe('$onChanges()', () => {
|
||||
it(`should set filter properties using the search values`, () => {
|
||||
let controller = $componentController('vnClientSearchPanel', {$window: $window});
|
||||
|
||||
expect(controller.filter).not.toBeDefined();
|
||||
spyOn(JSON, 'parse').and.returnValue({data: 'data'});
|
||||
controller.$onChanges();
|
||||
|
||||
expect(controller.filter).toBe(JSON.parse({data: 'data'}));
|
||||
});
|
||||
});
|
||||
|
|
|
@ -24,6 +24,7 @@ describe('Component VnClientWebAccess', () => {
|
|||
controller.client = {client: 'Bruce Wayne', account: 'Wayne Industries'};
|
||||
controller.account = {};
|
||||
controller.$onChanges();
|
||||
|
||||
expect(controller.account).toBe('Wayne Industries');
|
||||
});
|
||||
});
|
||||
|
@ -34,6 +35,7 @@ describe('Component VnClientWebAccess', () => {
|
|||
controller.newPassword = 'm24x8';
|
||||
controller.repeatPassword = 'm24x8';
|
||||
controller.onPassOpen();
|
||||
|
||||
expect(controller.newPassword).toBe('');
|
||||
expect(controller.repeatPassword).toBe('');
|
||||
});
|
||||
|
@ -52,22 +54,24 @@ describe('Component VnClientWebAccess', () => {
|
|||
});
|
||||
|
||||
describe(`when password is empty`, () => {
|
||||
it('should throw an error', () => {
|
||||
it(`should throw Passwords can't be empty error`, () => {
|
||||
let controller = $componentController('vnClientWebAccess', {$scope: $scope});
|
||||
controller.client = {id: '1234'};
|
||||
controller.newPassword = '';
|
||||
controller.onPassChange('ACCEPT');
|
||||
|
||||
expect(vnApp.showError).toHaveBeenCalledWith(`Passwords can't be empty`);
|
||||
});
|
||||
});
|
||||
|
||||
describe(`when passwords don't match`, () => {
|
||||
it('should throw an error', () => {
|
||||
it(`should throw Passwords don't match error`, () => {
|
||||
let controller = $componentController('vnClientWebAccess', {$scope: $scope});
|
||||
controller.client = {id: '1234'};
|
||||
controller.newPassword = 'm24x8';
|
||||
controller.repeatPassword = 'notMatchingPassword';
|
||||
controller.onPassChange('ACCEPT');
|
||||
|
||||
expect(vnApp.showError).toHaveBeenCalledWith(`Passwords don't match`);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -17,6 +17,7 @@ describe('Core', () => {
|
|||
|
||||
it('should define and set address property', () => {
|
||||
let controller = $componentController('vnAddressCreate', {$state: $state});
|
||||
|
||||
expect(controller.address.clientFk).toBe(1234);
|
||||
expect(controller.address.enabled).toBe(true);
|
||||
});
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
"eslint-config-loopback": "^4.0.0",
|
||||
"eslint-config-xo": "^0.17.0",
|
||||
"eslint-plugin-angular": "^1.4.1",
|
||||
"eslint-plugin-jasmine": "^2.8.4",
|
||||
"file-loader": "^0.9.0",
|
||||
"gulp": "^3.9.1",
|
||||
"gulp-concat": "^2.6.0",
|
||||
|
|
|
@ -1,32 +1,31 @@
|
|||
// import {catchErrors} from '../../../../../../services/utils/jasmineHelpers';
|
||||
// let app = require('../../../../server/server');
|
||||
import {catchErrors} from '../../../../../../services/utils/jasmineHelpers';
|
||||
let app = require('../../../../server/server');
|
||||
|
||||
// describe('Client Create()', () => {
|
||||
describe('Client Create()', () => {
|
||||
let data = {
|
||||
name: 'Max Eisenhardt',
|
||||
userName: 'Magneto',
|
||||
email: 'magneto@marvel.com',
|
||||
fi: 'X-tax number',
|
||||
socialName: 'The X-Men'
|
||||
};
|
||||
|
||||
// let data = {
|
||||
// name: 'Max Eisenhardt',
|
||||
// userName: 'Magneto',
|
||||
// email: 'magneto@marvel.com',
|
||||
// fi: 'X-tax number',
|
||||
// socialName: 'The X-Men'
|
||||
// }
|
||||
|
||||
// it('should createa new account', (done) => {
|
||||
// app.models.Client.createUserProfile(data, () => {
|
||||
// app.models.Account.findOne({where: {name: data.userName}})
|
||||
// .then(account => {
|
||||
// expect(account.name).toEqual(data.userName)
|
||||
// app.models.Client.findOne({where: {name: data.name}})
|
||||
// .then(client => {
|
||||
// expect(client.id).toEqual(account.id);
|
||||
// expect(client.name).toEqual(data.name);
|
||||
// expect(client.email).toEqual(data.email);
|
||||
// expect(client.fi).toEqual(data.fi);
|
||||
// expect(client.socialName).toEqual(data.socialName);
|
||||
// done();
|
||||
// });
|
||||
// })
|
||||
// .catch(catchErrors(done));
|
||||
// });
|
||||
// });
|
||||
// });
|
||||
it('should createa new account', done => {
|
||||
app.models.Client.createUserProfile(data, () => {
|
||||
app.models.Account.findOne({where: {name: data.userName}})
|
||||
.then(account => {
|
||||
expect(account.name).toEqual(data.userName);
|
||||
app.models.Client.findOne({where: {name: data.name}})
|
||||
.then(client => {
|
||||
expect(client.id).toEqual(account.id);
|
||||
expect(client.name).toEqual(data.name);
|
||||
expect(client.email).toEqual(data.email);
|
||||
expect(client.fi).toEqual(data.fi);
|
||||
expect(client.socialName).toEqual(data.socialName);
|
||||
done();
|
||||
});
|
||||
})
|
||||
.catch(catchErrors(done));
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,7 +1,4 @@
|
|||
module.exports = function(Agency) {
|
||||
|
||||
var serverFilter = {"where": {"isManaged": {"neq": 0}}};
|
||||
|
||||
module.exports = Agency => {
|
||||
let serverFilter = {where: {isManaged: {neq: 0}}};
|
||||
Agency.defineScope(serverFilter);
|
||||
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue