Fixes unit tests
This commit is contained in:
parent
6c6d8b9f3f
commit
3357150421
|
@ -19,25 +19,12 @@ import {Router} from '@angular/router';
|
|||
import {RouterTestingModule} from '@angular/router/testing';
|
||||
import {FormlyModule} from '@ngx-formly/core';
|
||||
import {FormlyMaterialModule} from '@ngx-formly/material';
|
||||
import {ChartsModule} from 'ng2-charts';
|
||||
import {MarkdownModule} from 'ngx-markdown';
|
||||
import {ApiService, MockEnvironment, SessionRedirectComponent, ToFormlyPipe} from 'sartography-workflow-lib';
|
||||
import {routes} from './app-routing.module';
|
||||
import {AppComponent} from './app.component';
|
||||
import {DashboardComponent} from './dashboard/dashboard.component';
|
||||
import {FooterComponent} from './footer/footer.component';
|
||||
import {HelpComponent} from './help/help.component';
|
||||
import {HomeComponent} from './home/home.component';
|
||||
import {InboxComponent} from './inbox/inbox.component';
|
||||
import {NavbarComponent} from './navbar/navbar.component';
|
||||
import {NotificationsComponent} from './notifications/notifications.component';
|
||||
import {ProfileComponent} from './profile/profile.component';
|
||||
import {StudiesComponent} from './studies/studies.component';
|
||||
import {StudyComponent} from './study/study.component';
|
||||
import {WorkflowFilesComponent} from './workflow-files/workflow-files.component';
|
||||
import {WorkflowFormComponent} from './workflow-form/workflow-form.component';
|
||||
import {WorkflowStepsMenuListComponent} from './workflow-steps-menu-list/workflow-steps-menu-list.component';
|
||||
import {WorkflowComponent} from './workflow/workflow.component';
|
||||
import {MockEnvironment} from './testing/environment.mock';
|
||||
|
||||
|
||||
describe('Router: App', () => {
|
||||
|
@ -50,49 +37,29 @@ describe('Router: App', () => {
|
|||
TestBed.configureTestingModule({
|
||||
declarations: [
|
||||
AppComponent,
|
||||
DashboardComponent,
|
||||
DashboardComponent,
|
||||
FooterComponent,
|
||||
HelpComponent,
|
||||
HomeComponent,
|
||||
InboxComponent,
|
||||
NavbarComponent,
|
||||
NotificationsComponent,
|
||||
ProfileComponent,
|
||||
SessionRedirectComponent,
|
||||
StudiesComponent,
|
||||
StudyComponent,
|
||||
ToFormlyPipe,
|
||||
WorkflowComponent,
|
||||
WorkflowFilesComponent,
|
||||
WorkflowFormComponent,
|
||||
WorkflowStepsMenuListComponent,
|
||||
],
|
||||
imports: [
|
||||
BrowserAnimationsModule,
|
||||
ChartsModule,
|
||||
FormlyMaterialModule,
|
||||
FormlyModule,
|
||||
FormsModule,
|
||||
HttpClientTestingModule,
|
||||
MarkdownModule,
|
||||
MatButtonModule,
|
||||
MatCardModule,
|
||||
MatFormFieldModule,
|
||||
MatIconModule,
|
||||
MatListModule,
|
||||
MatMenuModule,
|
||||
MatProgressBarModule,
|
||||
MatProgressSpinnerModule,
|
||||
MatSelectModule,
|
||||
MatSidenavModule,
|
||||
MatToolbarModule,
|
||||
NoopAnimationsModule,
|
||||
RouterTestingModule.withRoutes(routes),
|
||||
],
|
||||
providers: [
|
||||
HttpClient,
|
||||
ApiService,
|
||||
{provide: 'APP_ENVIRONMENT', useValue: mockEnvironment},
|
||||
{provide: APP_BASE_HREF, useValue: '/'},
|
||||
]
|
||||
|
@ -108,6 +75,6 @@ describe('Router: App', () => {
|
|||
console.log('mockEnvironment', mockEnvironment);
|
||||
const success = await fixture.ngZone.run(() => router.navigate(['']));
|
||||
expect(success).toBeTruthy();
|
||||
expect(location.path()).toBe('/home');
|
||||
expect(location.path()).toBe('/');
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import {APP_BASE_HREF} from '@angular/common';
|
||||
import {HttpClient} from '@angular/common/http';
|
||||
import {HttpClientTestingModule} from '@angular/common/http/testing';
|
||||
import {async, ComponentFixture, TestBed} from '@angular/core/testing';
|
||||
import {async, ComponentFixture, TestBed, waitForAsync} from '@angular/core/testing';
|
||||
import {MatIconModule} from '@angular/material/icon';
|
||||
import {FakeMatIconRegistry} from '@angular/material/icon/testing';
|
||||
import {MatMenuModule} from '@angular/material/menu';
|
||||
|
@ -18,7 +18,7 @@ describe('AppComponent', () => {
|
|||
const mockEnvironment = new MockEnvironment();
|
||||
const mockTitle = `'Once,' said the Mock Title at last, with a deep sigh, 'I was a real Title.'`;
|
||||
|
||||
beforeEach(async(() => {
|
||||
beforeEach(waitForAsync(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [
|
||||
AppComponent,
|
||||
|
|
|
@ -1,14 +1,33 @@
|
|||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import {MatButtonModule} from '@angular/material/button';
|
||||
import {MatCardModule} from '@angular/material/card';
|
||||
import {MatFormFieldModule} from '@angular/material/form-field';
|
||||
import {MatIconModule} from '@angular/material/icon';
|
||||
import {MatInputModule} from '@angular/material/input';
|
||||
import {NoopAnimationsModule} from '@angular/platform-browser/animations';
|
||||
import {Router} from '@angular/router';
|
||||
|
||||
import { CountComponent } from './count.component';
|
||||
|
||||
describe('CountComponent', () => {
|
||||
let component: CountComponent;
|
||||
let fixture: ComponentFixture<CountComponent>;
|
||||
const mockRouter = {navigate: jasmine.createSpy('navigate')};
|
||||
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
declarations: [ CountComponent ]
|
||||
declarations: [ CountComponent ],
|
||||
imports: [
|
||||
MatButtonModule,
|
||||
MatCardModule,
|
||||
MatFormFieldModule,
|
||||
MatIconModule,
|
||||
MatInputModule,
|
||||
NoopAnimationsModule,
|
||||
],
|
||||
providers: [
|
||||
{provide: Router, useValue: mockRouter},
|
||||
]
|
||||
})
|
||||
.compileComponents();
|
||||
});
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import {async, ComponentFixture, TestBed, waitForAsync} from '@angular/core/testing';
|
||||
|
||||
import { FooterComponent } from './footer.component';
|
||||
|
||||
|
@ -6,7 +6,7 @@ describe('FooterComponent', () => {
|
|||
let component: FooterComponent;
|
||||
let fixture: ComponentFixture<FooterComponent>;
|
||||
|
||||
beforeEach(async(() => {
|
||||
beforeEach(waitForAsync(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ FooterComponent ]
|
||||
})
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import {async, ComponentFixture, TestBed, waitForAsync} from '@angular/core/testing';
|
||||
|
||||
import { HomeComponent } from './home.component';
|
||||
|
||||
|
@ -6,7 +6,7 @@ describe('HomeComponent', () => {
|
|||
let component: HomeComponent;
|
||||
let fixture: ComponentFixture<HomeComponent>;
|
||||
|
||||
beforeEach(async(() => {
|
||||
beforeEach(waitForAsync(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ HomeComponent ]
|
||||
})
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import {QRCodeSVGModule} from 'ngx-qrcode-svg';
|
||||
|
||||
import { LabelLayoutComponent } from './label-layout.component';
|
||||
|
||||
|
@ -8,7 +9,10 @@ describe('LabelLayoutComponent', () => {
|
|||
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
declarations: [ LabelLayoutComponent ]
|
||||
declarations: [ LabelLayoutComponent ],
|
||||
imports: [
|
||||
QRCodeSVGModule,
|
||||
],
|
||||
})
|
||||
.compileComponents();
|
||||
});
|
||||
|
@ -16,6 +20,9 @@ describe('LabelLayoutComponent', () => {
|
|||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(LabelLayoutComponent);
|
||||
component = fixture.componentInstance;
|
||||
component.dateCreated = new Date();
|
||||
component.barCode = '123456789';
|
||||
component.initials = 'abc';
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import {async, ComponentFixture, TestBed, waitForAsync} from '@angular/core/testing';
|
||||
import {MatProgressSpinnerModule} from '@angular/material/progress-spinner';
|
||||
|
||||
import { LoadingComponent } from './loading.component';
|
||||
|
@ -7,7 +7,7 @@ describe('LoadingComponent', () => {
|
|||
let component: LoadingComponent;
|
||||
let fixture: ComponentFixture<LoadingComponent>;
|
||||
|
||||
beforeEach(async(() => {
|
||||
beforeEach(waitForAsync(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ LoadingComponent ],
|
||||
imports: [
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import {async, ComponentFixture, TestBed, waitForAsync} from '@angular/core/testing';
|
||||
import {MatButtonModule} from '@angular/material/button';
|
||||
import {MatIconModule} from '@angular/material/icon';
|
||||
import {MatToolbarModule} from '@angular/material/toolbar';
|
||||
|
||||
import { NavbarComponent } from './navbar.component';
|
||||
|
||||
|
@ -6,9 +9,14 @@ describe('NavbarComponent', () => {
|
|||
let component: NavbarComponent;
|
||||
let fixture: ComponentFixture<NavbarComponent>;
|
||||
|
||||
beforeEach(async(() => {
|
||||
beforeEach(waitForAsync(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ NavbarComponent ]
|
||||
declarations: [ NavbarComponent ],
|
||||
imports: [
|
||||
MatButtonModule,
|
||||
MatIconModule,
|
||||
MatToolbarModule,
|
||||
]
|
||||
})
|
||||
.compileComponents();
|
||||
}));
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import {ActivatedRoute, convertToParamMap} from '@angular/router';
|
||||
import {of} from 'rxjs';
|
||||
|
||||
import { PrintComponent } from './print.component';
|
||||
|
||||
|
@ -8,7 +10,13 @@ describe('PrintComponent', () => {
|
|||
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
declarations: [ PrintComponent ]
|
||||
declarations: [ PrintComponent ],
|
||||
providers: [
|
||||
{
|
||||
provide: ActivatedRoute,
|
||||
useValue: {queryParamMap: of(convertToParamMap({barCode: '123456789', initials: 'abc'}))}
|
||||
},
|
||||
]
|
||||
})
|
||||
.compileComponents();
|
||||
});
|
||||
|
|
|
@ -1,14 +1,33 @@
|
|||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import {MatButtonModule} from '@angular/material/button';
|
||||
import {MatCardModule} from '@angular/material/card';
|
||||
import {MatFormFieldModule} from '@angular/material/form-field';
|
||||
import {MatIconModule} from '@angular/material/icon';
|
||||
import {MatInputModule} from '@angular/material/input';
|
||||
import {NoopAnimationsModule} from '@angular/platform-browser/animations';
|
||||
import {Router} from '@angular/router';
|
||||
|
||||
import { SampleComponent } from './sample.component';
|
||||
|
||||
describe('SampleComponent', () => {
|
||||
let component: SampleComponent;
|
||||
let fixture: ComponentFixture<SampleComponent>;
|
||||
const mockRouter = {navigate: jasmine.createSpy('navigate')};
|
||||
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
declarations: [ SampleComponent ]
|
||||
declarations: [ SampleComponent ],
|
||||
imports: [
|
||||
MatButtonModule,
|
||||
MatCardModule,
|
||||
MatFormFieldModule,
|
||||
MatIconModule,
|
||||
MatInputModule,
|
||||
NoopAnimationsModule,
|
||||
],
|
||||
providers: [
|
||||
{provide: Router, useValue: mockRouter},
|
||||
]
|
||||
})
|
||||
.compileComponents();
|
||||
});
|
||||
|
|
|
@ -3,8 +3,7 @@ import {HttpClientTestingModule} from '@angular/common/http/testing';
|
|||
import {TestBed} from '@angular/core/testing';
|
||||
import {Router} from '@angular/router';
|
||||
import {RouterTestingModule} from '@angular/router/testing';
|
||||
import {SessionRedirectComponent} from '../components/session-redirect/session-redirect.component';
|
||||
import {MockEnvironment} from '../testing/mocks/environment.mocks';
|
||||
import {MockEnvironment} from '../testing/environment.mock';
|
||||
import {GoogleAnalyticsService} from './google-analytics.service';
|
||||
|
||||
describe('GoogleAnalyticsService', () => {
|
||||
|
@ -17,15 +16,8 @@ describe('GoogleAnalyticsService', () => {
|
|||
};
|
||||
|
||||
beforeEach(() => TestBed.configureTestingModule({
|
||||
declarations: [SessionRedirectComponent],
|
||||
imports: [
|
||||
HttpClientTestingModule,
|
||||
RouterTestingModule.withRoutes([
|
||||
{
|
||||
path: 'session/:token',
|
||||
component: SessionRedirectComponent
|
||||
}
|
||||
])
|
||||
],
|
||||
providers: [
|
||||
GoogleAnalyticsService,
|
||||
|
|
|
@ -1,14 +1,35 @@
|
|||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import {MatCardModule} from '@angular/material/card';
|
||||
import {MatOptionModule} from '@angular/material/core';
|
||||
import {MatFormFieldModule} from '@angular/material/form-field';
|
||||
import {MatIconModule} from '@angular/material/icon';
|
||||
import {MatInputModule} from '@angular/material/input';
|
||||
import {MatSelectModule} from '@angular/material/select';
|
||||
import {NoopAnimationsModule} from '@angular/platform-browser/animations';
|
||||
import {Router} from '@angular/router';
|
||||
|
||||
import { SettingsComponent } from './settings.component';
|
||||
|
||||
describe('SettingsComponent', () => {
|
||||
let component: SettingsComponent;
|
||||
let fixture: ComponentFixture<SettingsComponent>;
|
||||
const mockRouter = {navigate: jasmine.createSpy('navigate')};
|
||||
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
declarations: [ SettingsComponent ]
|
||||
declarations: [ SettingsComponent ],
|
||||
imports: [
|
||||
MatCardModule,
|
||||
MatFormFieldModule,
|
||||
MatIconModule,
|
||||
MatInputModule,
|
||||
MatOptionModule,
|
||||
MatSelectModule,
|
||||
NoopAnimationsModule,
|
||||
],
|
||||
providers: [
|
||||
{provide: Router, useValue: mockRouter},
|
||||
]
|
||||
})
|
||||
.compileComponents();
|
||||
});
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import {_has, environment} from './environment.runtime';
|
||||
import {hasEnv, environment} from './environment.runtime';
|
||||
|
||||
declare var ENV;
|
||||
|
||||
|
@ -7,7 +7,7 @@ describe('Environments', () => {
|
|||
expect(environment).toBeDefined();
|
||||
expect(environment.production).toEqual(false);
|
||||
expect(environment.api).toEqual('apiRoot');
|
||||
expect(environment.title).toEqual('Research Ramp-Up Toolkit');
|
||||
expect(environment.title).toEqual('COVID19 Testing Kiosk');
|
||||
expect(environment.googleAnalyticsKey).toEqual('UA-168203235-5');
|
||||
});
|
||||
|
||||
|
@ -19,29 +19,29 @@ describe('Environments', () => {
|
|||
googleAnalyticsKey: '$GOOGLE_ANALYTICS_KEY',
|
||||
};
|
||||
|
||||
expect(_has(env, 'production', '$PRODUCTION')).toBeFalse();
|
||||
expect(_has(env, 'api', '$API_URL')).toBeFalse();
|
||||
expect(_has(env, 'title', '$TITLE')).toBeFalse();
|
||||
expect(_has(env, 'googleAnalyticsKey', '$GOOGLE_ANALYTICS_KEY')).toBeFalse();
|
||||
expect(hasEnv(env, 'production', '$PRODUCTION')).toBeFalse();
|
||||
expect(hasEnv(env, 'api', '$API_URL')).toBeFalse();
|
||||
expect(hasEnv(env, 'title', '$TITLE')).toBeFalse();
|
||||
expect(hasEnv(env, 'googleAnalyticsKey', '$GOOGLE_ANALYTICS_KEY')).toBeFalse();
|
||||
|
||||
env.production = undefined;
|
||||
env.api = undefined;
|
||||
env.title = undefined;
|
||||
env.googleAnalyticsKey = undefined;
|
||||
|
||||
expect(_has(env, 'production', '$PRODUCTION')).toBeFalse();
|
||||
expect(_has(env, 'api', '$API_URL')).toBeFalse();
|
||||
expect(_has(env, 'title', '$TITLE')).toBeFalse();
|
||||
expect(_has(env, 'googleAnalyticsKey', '$GOOGLE_ANALYTICS_KEY')).toBeFalse();
|
||||
expect(hasEnv(env, 'production', '$PRODUCTION')).toBeFalse();
|
||||
expect(hasEnv(env, 'api', '$API_URL')).toBeFalse();
|
||||
expect(hasEnv(env, 'title', '$TITLE')).toBeFalse();
|
||||
expect(hasEnv(env, 'googleAnalyticsKey', '$GOOGLE_ANALYTICS_KEY')).toBeFalse();
|
||||
|
||||
env.production = 'something';
|
||||
env.api = 'something';
|
||||
env.title = 'something';
|
||||
env.googleAnalyticsKey = 'something';
|
||||
|
||||
expect(_has(env, 'production', '$PRODUCTION')).toBeTrue();
|
||||
expect(_has(env, 'api', '$API_URL')).toBeTrue();
|
||||
expect(_has(env, 'title', '$TITLE')).toBeTrue();
|
||||
expect(_has(env, 'googleAnalyticsKey', '$GOOGLE_ANALYTICS_KEY')).toBeTrue();
|
||||
expect(hasEnv(env, 'production', '$PRODUCTION')).toBeTrue();
|
||||
expect(hasEnv(env, 'api', '$API_URL')).toBeTrue();
|
||||
expect(hasEnv(env, 'title', '$TITLE')).toBeTrue();
|
||||
expect(hasEnv(env, 'googleAnalyticsKey', '$GOOGLE_ANALYTICS_KEY')).toBeTrue();
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue