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) {
|
module.exports = function(Self) {
|
||||||
Self.remoteMethodCtx('getStarredModules', {
|
Self.remoteMethodCtx('getStarredModules', {
|
||||||
description: 'returns the receved modules adding the starred property.',
|
description: 'returns the starred modules for the current user',
|
||||||
returns: {
|
returns: {
|
||||||
type: 'object',
|
type: 'object',
|
||||||
root: true
|
root: true
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
module.exports = function(Self) {
|
module.exports = function(Self) {
|
||||||
Self.remoteMethodCtx('toggleStarredModule', {
|
Self.remoteMethodCtx('toggleStarredModule', {
|
||||||
description: 'returns the receved modules adding the starred property.',
|
description: 'creates or deletes a starred module for the current user',
|
||||||
returns: {
|
returns: {
|
||||||
type: 'object',
|
type: 'object',
|
||||||
root: true
|
root: true
|
||||||
|
|
|
@ -48,12 +48,12 @@ export default class Controller extends Component {
|
||||||
const params = {moduleName: module.name};
|
const params = {moduleName: module.name};
|
||||||
const query = `starredModules/toggleStarredModule`;
|
const query = `starredModules/toggleStarredModule`;
|
||||||
this.$http.post(query, params).then(res => {
|
this.$http.post(query, params).then(res => {
|
||||||
this.vnApp.showSuccess(this.$t('Data saved!'));
|
|
||||||
if (res.data)
|
if (res.data)
|
||||||
module.starred = true;
|
module.starred = true;
|
||||||
else
|
else
|
||||||
module.starred = false;
|
module.starred = false;
|
||||||
|
|
||||||
|
this.vnApp.showSuccess(this.$t('Data saved!'));
|
||||||
this.countModules();
|
this.countModules();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,16 +46,30 @@ describe('Salix Component vnHome', () => {
|
||||||
|
|
||||||
describe('toggleStarredModule()', () => {
|
describe('toggleStarredModule()', () => {
|
||||||
it(`should set the received module as starred if it wasn't starred`, () => {
|
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'}];
|
controller._modules = [{module: 'client', name: 'Clients'}];
|
||||||
|
|
||||||
$httpBackend.whenRoute('GET', 'starredModules/getStarredModules').respond(expectedResponse);
|
$httpBackend.whenRoute('GET', 'starredModules/getStarredModules').respond(expectedResponse);
|
||||||
$httpBackend.expectGET('starredModules/getStarredModules').respond(expectedResponse);
|
$httpBackend.expectPOST('starredModules/toggleStarredModule').respond(expectedResponse);
|
||||||
controller.getStarredModules();
|
controller.toggleStarredModule(controller._modules[0], event);
|
||||||
$httpBackend.flush();
|
$httpBackend.flush();
|
||||||
|
|
||||||
expect(controller._modules.length).toEqual(1);
|
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