Skip to content

Commit

Permalink
Use new DI in tests entities
Browse files Browse the repository at this point in the history
  • Loading branch information
William Marques committed May 15, 2018
1 parent 9fe1f65 commit 3c3a4b8
Show file tree
Hide file tree
Showing 18 changed files with 12 additions and 90 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ describe('Component Tests', () => {
imports: [<%=angularXAppName%>TestModule],
declarations: [ActivateComponent],
providers: [
ActivateService,
{
provide: ActivatedRoute,
useValue: new MockActivatedRoute({'key': 'ABC123'})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ describe('Component Tests', () => {
imports: [<%=angularXAppName%>TestModule],
declarations: [PasswordResetFinishComponent],
providers: [
PasswordResetFinishService,
{
provide: ActivatedRoute,
useValue: new MockActivatedRoute({'key': 'XYZPDQ'})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ describe('Component Tests', () => {
imports: [<%=angularXAppName%>TestModule],
declarations: [PasswordResetInitComponent],
providers: [
PasswordResetInitService,
{
provide: Renderer,
useValue: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ import { Observable, of, throwError } from 'rxjs';
import { <%=angularXAppName%>TestModule } from '../../../test.module';
import { PasswordComponent } from 'app/account/password/password.component';
import { PasswordService } from 'app/account/password/password.service';
import { Principal } from 'app/core/auth/principal.service';
import { AccountService } from 'app/core/auth/account.service';
<%_ if (websocket === 'spring-websocket') { _%>
import { <%=jhiPrefixCapitalized%>TrackerService } from 'app/core/tracker/tracker.service';
import { MockTrackerService } from '../../../helpers/mock-tracker.service';
Expand All @@ -43,15 +41,12 @@ describe('Component Tests', () => {
imports: [<%=angularXAppName%>TestModule],
declarations: [PasswordComponent],
providers: [
Principal,
AccountService,
<%_ if (websocket === 'spring-websocket') { _%>
{
provide: <%=jhiPrefixCapitalized%>TrackerService,
useClass: MockTrackerService
},
}
<%_ } _%>
PasswordService
]
})
.overrideTemplate(PasswordComponent, '')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,7 @@ describe('Component Tests', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [<%=angularXAppName%>TestModule],
declarations: [RegisterComponent],
providers: [
Register
]
declarations: [RegisterComponent]
})
.overrideTemplate(RegisterComponent, '')
.compileComponents();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,7 @@ describe('Component Tests', () => {

fixture = TestBed.configureTestingModule({
imports: [<%=angularXAppName%>TestModule],
declarations: [SessionsComponent],
providers: [
SessionsService
]
declarations: [SessionsComponent]
})
.overrideTemplate(SessionsComponent, '')
.createComponent(SessionsComponent);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,8 @@
import { ComponentFixture, TestBed, async } from '@angular/core/testing';
import { Observable, of } from 'rxjs';
import { HttpHeaders, HttpResponse } from '@angular/common/http';
import { NgbPaginationConfig } from '@ng-bootstrap/ng-bootstrap';

import { <%=angularXAppName%>TestModule } from '../../../test.module';
import { PaginationConfig } from 'app/blocks/config/uib-pagination.config';
import { AuditsComponent } from 'app/admin/audits/audits.component';
import { AuditsService } from 'app/admin/audits/audits.service';
import { Audit } from 'app/admin/audits/audit.model';
Expand Down Expand Up @@ -63,9 +61,7 @@ describe('Component Tests', () => {
imports: [<%=angularXAppName%>TestModule],
declarations: [AuditsComponent],
providers: [
AuditsService,
NgbPaginationConfig,
PaginationConfig
AuditsService
]
})
.overrideTemplate(AuditsComponent, '')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,6 @@ describe('Service Tests', () => {
TestBed.configureTestingModule({
imports: [
HttpClientTestingModule
],
providers: [
AuditsService
]
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,7 @@ describe('Component Tests', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [<%=angularXAppName%>TestModule],
declarations: [<%=jhiPrefixCapitalized%>HealthCheckComponent],
providers: [
<%=jhiPrefixCapitalized%>HealthService
]
declarations: [<%=jhiPrefixCapitalized%>HealthCheckComponent]
})
.overrideTemplate(<%=jhiPrefixCapitalized%>HealthCheckComponent, '')
.compileComponents();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,7 @@ describe('Component Tests', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [<%=angularXAppName%>TestModule],
declarations: [UserMgmtDeleteDialogComponent],
providers: [
UserService
]
declarations: [UserMgmtDeleteDialogComponent]
})
.overrideTemplate(UserMgmtDeleteDialogComponent, '')
.compileComponents();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ describe('Component Tests', () => {
imports: [<%=angularXAppName%>TestModule],
declarations: [UserMgmtUpdateComponent],
providers: [
UserService,
{
provide: ActivatedRoute,
useValue: route
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,7 @@ describe('Component Tests', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [<%=angularXAppName%>TestModule],
declarations: [UserMgmtComponent],
providers: [
UserService
]
declarations: [UserMgmtComponent]
})
.overrideTemplate(UserMgmtComponent, '')
.compileComponents();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ describe('Service Tests', () => {
HttpClientTestingModule
],
providers: [
JhiDateUtils,
UserService
JhiDateUtils
]
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,13 @@ import { <%= angularXAppName %>SharedModule } from 'app/shared';
import { <%= angularXAppName %>AdminModule } from 'app/admin/admin.module';
<%_ }}); _%>
import {
<%= entityAngularName %>Service,
<%= entityAngularName %>Component,
<%= entityAngularName %>DetailComponent,
<%= entityAngularName %>UpdateComponent,
<%= entityAngularName %>DeletePopupComponent,
<%= entityAngularName %>DeleteDialogComponent,
<%= entityInstance %>Route,
<%= entityInstance %>PopupRoute,
<%= entityAngularName %>Resolve
<%= entityInstance %>PopupRoute
} from './';

const ENTITY_STATES = [
Expand Down Expand Up @@ -63,10 +61,6 @@ const ENTITY_STATES = [
<%= entityAngularName %>DeleteDialogComponent,
<%= entityAngularName %>DeletePopupComponent,
],
providers: [
<%= entityAngularName %>Service,
<%= entityAngularName %>Resolve
],
schemas: [CUSTOM_ELEMENTS_SCHEMA]
})
export class <%= angularXAppName %><%= entityAngularName %>Module {}
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,7 @@ describe('Component Tests', () => {
beforeEach(() => {
TestBed.configureTestingModule({
imports: [<%=angularXAppName%>TestModule],
declarations: [<%= entityAngularName %>DeleteDialogComponent],
providers: [
<%= entityAngularName %>Service
]
declarations: [<%= entityAngularName %>DeleteDialogComponent]
})
.overrideTemplate(<%= entityAngularName %>DeleteDialogComponent, '')
.compileComponents();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,28 +29,6 @@ import { <%= entityAngularName %>UpdateComponent } from 'app/entities/<%= entity
import { <%= entityAngularName %>Service } from 'app/entities/<%= entityFolderName %>/<%= entityFileName %>.service';
import { <%= entityAngularName %> } from 'app/shared/model/<%= entityModelFileName %>.model';

<%_
let hasRelationshipQuery = false;
Object.keys(differentRelationships).forEach(key => {
const hasAnyRelationshipQuery = differentRelationships[key].some(rel =>
(rel.relationshipType === 'one-to-one' && rel.ownerSide === true && rel.otherEntityName !== 'user')
|| rel.relationshipType !== 'one-to-many'
);
if (hasAnyRelationshipQuery) {
hasRelationshipQuery = true;
}
if (differentRelationships[key].some(rel => rel.relationshipType !== 'one-to-many')) {
const uniqueRel = differentRelationships[key][0];
if (uniqueRel.otherEntityAngularName !== entityAngularName) {
const modulePath = uniqueRel.otherEntityAngularName === 'User' ?
`app/core`
: `app/entities/${uniqueRel.otherEntityClientRootFolder ? `${uniqueRel.otherEntityClientRootFolder}/` : ''}${uniqueRel.otherEntityFileName}`
_%>
import { <%= uniqueRel.otherEntityAngularName%>Service } from '<%= modulePath %>';
<%_ }
}
}); _%>

describe('Component Tests', () => {

describe('<%= entityAngularName %> Management Update Component', () => {
Expand All @@ -61,19 +39,7 @@ describe('Component Tests', () => {
beforeEach(() => {
TestBed.configureTestingModule({
imports: [<%=angularXAppName%>TestModule],
declarations: [<%= entityAngularName %>UpdateComponent],
providers: [
<%_ Object.keys(differentRelationships).forEach(key => {
if (differentRelationships[key].some(rel => rel.relationshipType !== 'one-to-many')) {
const uniqueRel = differentRelationships[key][0];
if (uniqueRel.otherEntityAngularName !== entityAngularName) { _%>
<%= uniqueRel.otherEntityAngularName %>Service,
<%_
}
}
}); _%>
<%= entityAngularName %>Service
]
declarations: [<%= entityAngularName %>UpdateComponent]
})
.overrideTemplate(<%= entityAngularName %>UpdateComponent, '')
.compileComponents();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ describe('Component Tests', () => {
imports: [<%=angularXAppName%>TestModule],
declarations: [<%= entityAngularName %>Component],
providers: [
<%= entityAngularName %>Service<% if (pagination !== 'no') { %>, {
<% if (pagination !== 'no') { %> {
provide: ActivatedRoute,
useValue: {
data: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,6 @@ describe('Service Tests', () => {
TestBed.configureTestingModule({
imports: [
HttpClientTestingModule
],
providers: [
<%= entityAngularName %>Service
]
});
injector = getTestBed();
Expand Down

0 comments on commit 3c3a4b8

Please sign in to comment.