final amends on tests and model descriptions
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
parent
021601fb26
commit
fe7017f83c
|
@ -1,6 +1,6 @@
|
|||
module.exports = function(Self) {
|
||||
Self.remoteMethodCtx('getStarredModules', {
|
||||
description: 'returns the receved modules adding the starred property.',
|
||||
description: 'returns the starred modules for the current user',
|
||||
returns: {
|
||||
type: 'object',
|
||||
root: true
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
module.exports = function(Self) {
|
||||
Self.remoteMethodCtx('toggleStarredModule', {
|
||||
description: 'returns the receved modules adding the starred property.',
|
||||
description: 'creates or deletes a starred module for the current user',
|
||||
returns: {
|
||||
type: 'object',
|
||||
root: true
|
||||
|
|
|
@ -48,12 +48,12 @@ export default class Controller extends Component {
|
|||
const params = {moduleName: module.name};
|
||||
const query = `starredModules/toggleStarredModule`;
|
||||
this.$http.post(query, params).then(res => {
|
||||
this.vnApp.showSuccess(this.$t('Data saved!'));
|
||||
if (res.data)
|
||||
module.starred = true;
|
||||
else
|
||||
module.starred = false;
|
||||
|
||||
this.vnApp.showSuccess(this.$t('Data saved!'));
|
||||
this.countModules();
|
||||
});
|
||||
}
|
||||
|
|
|
@ -46,16 +46,30 @@ describe('Salix Component vnHome', () => {
|
|||
|
||||
describe('toggleStarredModule()', () => {
|
||||
it(`should set the received module as starred if it wasn't starred`, () => {
|
||||
const expectedResponse = [];
|
||||
const expectedResponse = [{id: 1, moduleFk: 'Clients', workerFk: 9}];
|
||||
const event = new Event('target');
|
||||
controller._modules = [{module: 'client', name: 'Clients'}];
|
||||
|
||||
$httpBackend.whenRoute('GET', 'starredModules/getStarredModules').respond(expectedResponse);
|
||||
$httpBackend.expectGET('starredModules/getStarredModules').respond(expectedResponse);
|
||||
controller.getStarredModules();
|
||||
$httpBackend.expectPOST('starredModules/toggleStarredModule').respond(expectedResponse);
|
||||
controller.toggleStarredModule(controller._modules[0], event);
|
||||
$httpBackend.flush();
|
||||
|
||||
expect(controller._modules.length).toEqual(1);
|
||||
expect(controller._modules[0].starred).toBeUndefined();
|
||||
expect(controller._modules[0].starred).toBe(true);
|
||||
});
|
||||
|
||||
it(`should set the received module as regular if it was starred`, () => {
|
||||
const event = new Event('target');
|
||||
controller._modules = [{module: 'client', name: 'Clients', starred: true}];
|
||||
|
||||
$httpBackend.whenRoute('GET', 'starredModules/getStarredModules').respond([]);
|
||||
$httpBackend.expectPOST('starredModules/toggleStarredModule').respond(undefined);
|
||||
controller.toggleStarredModule(controller._modules[0], event);
|
||||
$httpBackend.flush();
|
||||
|
||||
expect(controller._modules.length).toEqual(1);
|
||||
expect(controller._modules[0].starred).toBe(false);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue