Skip to content

Commit

Permalink
Angular oauth2 / fix, use alertbus
Browse files Browse the repository at this point in the history
  • Loading branch information
Bolo89 committed May 18, 2022
1 parent d89dda9 commit 8ed3d2c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,8 @@ export default defineComponent({
if (props.project.folder !== '') {
await angularService
.addOauth2(toProject(props.project as ProjectToUpdate))
.then(() => toastService.success('Oauth2 successfully added'))
.catch(error => {
logger.error('Adding Oauth2 to project failed', error);
toastService.error('Adding Oauth2 to project failed ' + error);
});
.then(() => alertBus.success('OAuth2 successfully added'))
.catch(error => alertBus.error(`Adding Oauth2 to project failed ${error}`));
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { shallowMount, VueWrapper } from '@vue/test-utils';
import { stubAngularService } from '../../../domain/client/AngularService.fixture';
import { ProjectToUpdate } from '@/springboot/primary/ProjectToUpdate';
import { createProjectToUpdate } from '../../ProjectToUpdate.fixture';
import { stubLogger } from '../../../../common/domain/Logger.fixture';
import { AngularService } from '@/springboot/domain/client/AngularService';
import { AngularGeneratorVue } from '@/springboot/primary/generator/angular-generator';
import { AlertBusFixture, stubAlertBus } from '../../../../common/domain/AlertBus.fixture';
Expand Down Expand Up @@ -148,8 +147,8 @@ describe('AngularGenerator', () => {
it('should add Oauth2 when project path is filled', async () => {
const angularService = stubAngularService();
angularService.addOauth2.resolves({});
const toastService = stubToastService();
await wrap({ angularService, project: createProjectToUpdate({ folder: 'project/path' }), toastService });
const alertBus = stubAlertBus();
await wrap({ angularService, project: createProjectToUpdate({ folder: 'project/path' }), alertBus });

await component.addOauth2();

Expand All @@ -161,19 +160,17 @@ describe('AngularGenerator', () => {
packageName: 'tech.jhipster.beer',
serverPort: 8080,
});
expectToastSuccessToBe(toastService, 'Oauth2 successfully added');
expectAlertSuccessToBe(alertBus, 'OAuth2 successfully added');
});

it('should handle error on adding Oauth2 failure', async () => {
const logger = stubLogger();
const angularService = stubAngularService();
const toastService = stubToastService();
const alertBus = stubAlertBus();
angularService.addOauth2.rejects('error');
await wrap({ angularService, logger, project: createProjectToUpdate({ folder: 'path' }), toastService });
await wrap({ angularService, project: createProjectToUpdate({ folder: 'path' }), alertBus });

await component.addOauth2();

expectLoggerErrorToBe(logger, 'Adding Oauth2 to project failed');
expectToastErrorToBe(toastService, 'Adding Oauth2 to project failed error');
expectAlertErrorToBe(alertBus, 'Adding Oauth2 to project failed error');
});
});

0 comments on commit 8ed3d2c

Please sign in to comment.