Skip to content

Commit

Permalink
Merge pull request #150 from wantero/master
Browse files Browse the repository at this point in the history
Configuração do Projeto para implementar os Testes com Karma/Jasmine
  • Loading branch information
raffacabofrio authored Dec 6, 2018
2 parents 69622ba + c613018 commit 95592dd
Show file tree
Hide file tree
Showing 25 changed files with 430 additions and 30 deletions.
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,11 @@
"build-stg": "ng build --configuration=stage",
"build-prod": "ng build --configuration=production",
"test": "ng test",
"test-single": "ng test --watch=false --progress",
"lint": "ng lint",
"e2e": "ng e2e",
"prepush": "ng lint"
"precommit": "npm run lint",
"prepush": "npm run lint && npm run test-single && npm run build-prod"
},
"private": true,
"dependencies": {
Expand Down
32 changes: 29 additions & 3 deletions src/app/app.component.spec.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,45 @@
import { TestBed, async } from '@angular/core/testing';
import {RouterTestingModule} from '@angular/router/testing';
import { HttpClient, HttpHandler } from '@angular/common/http';
import { AppConfigModule } from './app-config.module';

import { AppComponent } from './app.component';
import { HeaderComponent } from './components/header/header.component';
import { AlertComponent } from './core/directives/alert/alert.component';
import { FooterComponent } from './components/footer/footer.component';

import { UserService } from './core/services/user/user.service';
import { AuthenticationService } from './core/services/authentication/authentication.service';
import { AlertService } from './core/services/alert/alert.service';

describe('AppComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [
AppComponent
AppComponent,
HeaderComponent,
AlertComponent,
FooterComponent
],
imports: [
RouterTestingModule,
AppConfigModule
],
providers: [
UserService,
AuthenticationService,
AlertService,
HttpClient,
HttpHandler
]
}).compileComponents();
}));
it('should create the app', async(() => {
const fixture = TestBed.createComponent(AppComponent);
const app = fixture.debugElement.componentInstance;
expect(app).toBeTruthy();
}));
it(`should have as title 'app'`, async(() => {
/*it(`should have as title 'app'`, async(() => {
const fixture = TestBed.createComponent(AppComponent);
const app = fixture.debugElement.componentInstance;
expect(app.title).toEqual('app');
Expand All @@ -23,5 +49,5 @@ describe('AppComponent', () => {
fixture.detectChanges();
const compiled = fixture.debugElement.nativeElement;
expect(compiled.querySelector('h1').textContent).toContain('Welcome to angular!');
}));
}));*/
});
27 changes: 26 additions & 1 deletion src/app/components/account/account.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,41 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { By } from '@angular/platform-browser';
import { DebugElement } from '@angular/core';
import { RouterTestingModule } from '@angular/router/testing';
import { HttpClient, HttpHandler } from '@angular/common/http';

import { AccountComponent } from './account.component';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { NgxMaskModule } from 'ngx-mask';

import { AppConfigModule } from '../../app-config.module';
import { UserService } from '../../core/services/user/user.service';
import { AlertService } from '../../core/services/alert/alert.service';
import { AddressService } from '../../core/services/address/address.service';

describe('AccountComponent', () => {
let component: AccountComponent;
let fixture: ComponentFixture<AccountComponent>;

beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ AccountComponent ]
declarations: [
AccountComponent
],
imports: [
FormsModule,
ReactiveFormsModule,
NgxMaskModule.forRoot(),
RouterTestingModule,
AppConfigModule
],
providers: [
UserService,
AlertService,
AddressService,
HttpClient,
HttpHandler
]
})
.compileComponents();
}));
Expand Down
21 changes: 20 additions & 1 deletion src/app/components/book/details/details.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,35 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { By } from '@angular/platform-browser';
import { DebugElement } from '@angular/core';
import { RouterTestingModule } from '@angular/router/testing';
import { HttpClient, HttpHandler } from '@angular/common/http';
import { NgbModule, NgbModalModule } from '@ng-bootstrap/ng-bootstrap';

import { DetailsComponent } from './details.component';

import { AppConfigModule } from '../../../app-config.module';
import { UserService } from '../../../core/services/user/user.service';

describe('DetailsComponent', () => {
let component: DetailsComponent;
let fixture: ComponentFixture<DetailsComponent>;

beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ DetailsComponent ]
declarations: [
DetailsComponent
],
imports: [
RouterTestingModule,
AppConfigModule,
NgbModule.forRoot(),
NgbModalModule
],
providers: [
UserService,
HttpClient,
HttpHandler
]
})
.compileComponents();
}));
Expand Down
22 changes: 21 additions & 1 deletion src/app/components/book/donate/donate.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,36 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { By } from '@angular/platform-browser';
import { DebugElement } from '@angular/core';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { Ng2SmartTableModule } from 'ng2-smart-table';
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
import { RouterTestingModule } from '@angular/router/testing';

import { DonateComponent } from './donate.component';

import { AppConfigModule } from '../../../app-config.module';
import { AlertService } from '../../../core/services/alert/alert.service';

describe('DonateComponent', () => {
let component: DonateComponent;
let fixture: ComponentFixture<DonateComponent>;

beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ DonateComponent ]
declarations: [
DonateComponent
],
imports: [
FormsModule,
ReactiveFormsModule,
Ng2SmartTableModule,
AppConfigModule,
RouterTestingModule
],
providers: [
NgbActiveModal,
AlertService
]
})
.compileComponents();
}));
Expand Down
11 changes: 10 additions & 1 deletion src/app/components/book/donations/donations.component.spec.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,23 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { Ng2SmartTableModule } from 'ng2-smart-table';

import { DonationsComponent } from './donations.component';

import { AppConfigModule } from '../../../app-config.module';

describe('DonationsComponent', () => {
let component: DonationsComponent;
let fixture: ComponentFixture<DonationsComponent>;

beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ DonationsComponent ]
declarations: [
DonationsComponent
],
imports: [
Ng2SmartTableModule,
AppConfigModule
]
})
.compileComponents();
}));
Expand Down
36 changes: 35 additions & 1 deletion src/app/components/book/form/form.component.spec.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,48 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { ImageUploadModule } from 'ng2-imageupload';
import { NgbModule, NgbModalModule } from '@ng-bootstrap/ng-bootstrap';
import { RouterTestingModule } from '@angular/router/testing';
import { HttpClient, HttpHandler } from '@angular/common/http';
import { Ng2ImgMaxService, ImgMaxSizeService, ImgExifService, ImgMaxPXSizeService } from 'ng2-img-max';
import { Ng2PicaService, ImgExifService as ImgPicaService } from 'ng2-pica';

import { FormComponent } from './form.component';

import { AppConfigModule } from '../../../app-config.module';
import { UserService } from '../../../core/services/user/user.service';
import { AlertService } from '../../../core/services/alert/alert.service';

describe('FormComponent', () => {
let component: FormComponent;
let fixture: ComponentFixture<FormComponent>;

beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ FormComponent ]
declarations: [
FormComponent
],
imports: [
FormsModule,
ReactiveFormsModule,
ImageUploadModule,
NgbModule.forRoot(),
NgbModalModule,
RouterTestingModule,
AppConfigModule
],
providers: [
HttpClient,
HttpHandler,
UserService,
AlertService,
Ng2ImgMaxService,
ImgMaxSizeService,
ImgExifService,
ImgMaxPXSizeService,
Ng2PicaService,
ImgPicaService
]
})
.compileComponents();
}));
Expand Down
23 changes: 22 additions & 1 deletion src/app/components/book/list/list.component.spec.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,35 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { Ng2SmartTableModule } from 'ng2-smart-table';
import { RouterTestingModule } from '@angular/router/testing';
import { NgbModule, NgbModalModule } from '@ng-bootstrap/ng-bootstrap';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';

import { ListComponent } from './list.component';

import { AppConfigModule } from '../../../app-config.module';
import { AlertService } from '../../../core/services/alert/alert.service';

describe('ListComponent', () => {
let component: ListComponent;
let fixture: ComponentFixture<ListComponent>;

beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ ListComponent ]
declarations: [
ListComponent
],
imports: [
Ng2SmartTableModule,
AppConfigModule,
RouterTestingModule,
NgbModule.forRoot(),
NgbModalModule,
FormsModule,
ReactiveFormsModule
],
providers: [
AlertService
]
})
.compileComponents();
}));
Expand Down
30 changes: 29 additions & 1 deletion src/app/components/book/request/request.component.spec.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,42 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { NgbModule, NgbModalModule } from '@ng-bootstrap/ng-bootstrap';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
import { HttpClient, HttpHandler } from '@angular/common/http';
import { RouterTestingModule } from '@angular/router/testing';
import { Ng2SmartTableModule } from 'ng2-smart-table';

import { RequestComponent } from './request.component';

import { AppConfigModule } from '../../../app-config.module';
import { UserService } from '../../../core/services/user/user.service';
import { AlertService } from '../../../core/services/alert/alert.service';

describe('RequestComponent', () => {
let component: RequestComponent;
let fixture: ComponentFixture<RequestComponent>;

beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ RequestComponent ]
declarations: [
RequestComponent
],
imports: [
FormsModule,
ReactiveFormsModule,
NgbModule.forRoot(),
NgbModalModule,
Ng2SmartTableModule,
AppConfigModule,
RouterTestingModule
],
providers: [
NgbActiveModal,
HttpClient,
HttpHandler,
UserService,
AlertService
]
})
.compileComponents();
}));
Expand Down
14 changes: 13 additions & 1 deletion src/app/components/book/requesteds/requesteds.component.spec.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,26 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { Ng2SmartTableModule } from 'ng2-smart-table';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';

import { RequestedsComponent } from './requesteds.component';

import { AppConfigModule } from '../../../app-config.module';

describe('RequestedsComponent', () => {
let component: RequestedsComponent;
let fixture: ComponentFixture<RequestedsComponent>;

beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ RequestedsComponent ]
declarations: [
RequestedsComponent
],
imports: [
Ng2SmartTableModule,
AppConfigModule,
FormsModule,
ReactiveFormsModule
]
})
.compileComponents();
}));
Expand Down
Loading

0 comments on commit 95592dd

Please sign in to comment.