Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Vue] Increase Vue code coverage #19405

Merged
merged 2 commits into from
Aug 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,7 @@ module.exports = {
coverageThreshold: {
global: {
statements: 80,
<%_ if (microfrontend) { _%>
branches: 57,
<%_ } else { _%>
branches: 60,
<%_ } _%>
functions: 70,
lines: 80,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ describe('Alert Service test suite', () => {
// WHEN
alertService.showError((<any>vueInstance) as Vue, <% if (enableTranslation) { %>translationKey<%} else {%>message<% } %>);

//THEN
// THEN
<%_ if (enableTranslation) { _%>
expect(translationStub.withArgs(translationKey).callCount).toEqual(1);
<%_ } _%>
Expand Down Expand Up @@ -71,7 +71,7 @@ describe('Alert Service test suite', () => {
// WHEN
alertService.showHttpError((<any>vueInstance) as Vue, httpErrorResponse);

//THEN
// THEN
<%_ if (enableTranslation) { _%>
expect(translationStub.withArgs(translationKey).callCount).toEqual(1);
<%_ } _%>
Expand Down Expand Up @@ -107,7 +107,7 @@ describe('Alert Service test suite', () => {
// WHEN
alertService.showHttpError((<any>vueInstance) as Vue, httpErrorResponse);

//THEN
// THEN
<%_ if (enableTranslation) { _%>
expect(translationStub.withArgs(translationKey, { entityName: 'DummyEntity' }).callCount).toEqual(1);
<%_ } _%>
Expand All @@ -121,4 +121,43 @@ describe('Alert Service test suite', () => {
})
).toBeTruthy();
});

it('should show error toast with data.message when http status = 400 and entity headers', async () => {
const message = 'Validation error';
const httpErrorResponse = {
status: 400,
headers: {
'x-jhipsterapp-error400': 'error',
'x-jhipsterapp-params400': 'dummyEntity',
},
data: {
message,
fieldErrors: {
'field1': 'error1',
},
},
};

<%_ if (enableTranslation) { _%>
// GIVEN
translationStub.withArgs(message).returns(message);
<%_ } _%>

// WHEN
alertService.showHttpError((<any>vueInstance) as Vue, httpErrorResponse);

// THEN
<%_ if (enableTranslation) { _%>
expect(translationStub.withArgs(message).callCount).toEqual(1);
<%_ } _%>
expect(
toastStub.calledOnceWith(message, {
toaster: 'b-toaster-top-center',
title: 'Error',
variant: 'danger',
solid: true,
autoHideDelay: 5000,
})
).toBeTruthy();
});
});