Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
artemsky committed May 9, 2018
1 parent 9199dd5 commit 918a4e8
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 29 deletions.
4 changes: 2 additions & 2 deletions angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@
"example/styles.scss"
],
"assets": [
"example/assets",
"example/favicon.ico"
{ "glob": "**/*", "input": "example/assets/", "output": "/assets/" },
{ "glob": "example/favicon.ico", "input": "/src", "output": "/" }
]
}
},
Expand Down
38 changes: 13 additions & 25 deletions example/app/app.component.spec.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
/* tslint:disable:no-unused-variable */

import { FormsModule } from '@angular/forms';
import { TestBed, async } from '@angular/core/testing';
import { TestBed, ComponentFixture, async } from '@angular/core/testing';
import { AppComponent } from './app.component';
import {SnotifyModule, SnotifyService, ToastDefaults} from 'ng-snotify';
import {SnotifyPosition} from '../../src/snotify/enums/SnotifyPosition.enum';

describe('NgSnotify Testing', () => {
beforeEach(() => {
let component: AppComponent;
let fixture: ComponentFixture<AppComponent>;

beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [ FormsModule, SnotifyModule ],
declarations: [
Expand All @@ -17,36 +20,34 @@ describe('NgSnotify Testing', () => {
{ provide: 'SnotifyToastConfig', useValue: ToastDefaults},
SnotifyService
]
});
}).compileComponents();
}));

beforeEach(() => {
fixture = TestBed.createComponent(AppComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create the app', (done) => {
const fixture = TestBed.createComponent(AppComponent);
const app = fixture.debugElement.componentInstance;
expect(app).toBeTruthy();
expect(component).toBeTruthy();
done();
});

it(`should render title in a h1 tag 'Ng-Snotify'`, (done) => {
const fixture = TestBed.createComponent(AppComponent);
fixture.detectChanges();
const compiled = fixture.debugElement.nativeElement;
expect(compiled.querySelector('.brand h1').textContent).toContain('Ng-Snotify');
done();
});

it(`should init basic options`, (done) => {
const fixture = TestBed.createComponent(AppComponent);
const app = fixture.debugElement.componentInstance;
const service: SnotifyService = fixture.debugElement.injector.get(SnotifyService);
fixture.detectChanges();
expect(service.config).toEqual(jasmine.objectContaining(ToastDefaults));
done();
});

it('should create success toast with body', (done) => {
const fixture = TestBed.createComponent(AppComponent);
const app = fixture.debugElement.componentInstance;
const service: SnotifyService = fixture.debugElement.injector.get(SnotifyService);
fixture.detectChanges();
const compiled = fixture.debugElement.nativeElement;
Expand All @@ -57,8 +58,6 @@ describe('NgSnotify Testing', () => {
});

it('should create simple toast with body and title', (done) => {
const fixture = TestBed.createComponent(AppComponent);
const app = fixture.debugElement.componentInstance;
const service: SnotifyService = fixture.debugElement.injector.get(SnotifyService);
fixture.detectChanges();
const compiled = fixture.debugElement.nativeElement;
Expand All @@ -71,9 +70,6 @@ describe('NgSnotify Testing', () => {

it('should execute confirm button action', (done) => {
let result = null;

const fixture = TestBed.createComponent(AppComponent);
const app = fixture.debugElement.componentInstance;
const service: SnotifyService = fixture.debugElement.injector.get(SnotifyService);
fixture.detectChanges();
const compiled = fixture.debugElement.nativeElement;
Expand All @@ -91,8 +87,6 @@ describe('NgSnotify Testing', () => {
});

it('should create prompt toast with 4 buttons', (done) => {
const fixture = TestBed.createComponent(AppComponent);
const app = fixture.debugElement.componentInstance;
const service: SnotifyService = fixture.debugElement.injector.get(SnotifyService);
fixture.detectChanges();
const compiled = fixture.debugElement.nativeElement;
Expand All @@ -113,8 +107,6 @@ describe('NgSnotify Testing', () => {
});

it('should create html toast with html content', (done) => {
const fixture = TestBed.createComponent(AppComponent);
const app = fixture.debugElement.componentInstance;
const service: SnotifyService = fixture.debugElement.injector.get(SnotifyService);
fixture.detectChanges();
const compiled = fixture.debugElement.nativeElement;
Expand All @@ -125,8 +117,6 @@ describe('NgSnotify Testing', () => {
});

it('should create 3 toasts max at rightTop position', (done) => {
const fixture = TestBed.createComponent(AppComponent);
const app = fixture.debugElement.componentInstance;
const service: SnotifyService = fixture.debugElement.injector.get(SnotifyService);
const compiled = fixture.debugElement.nativeElement;
fixture.detectChanges();
Expand All @@ -150,8 +140,6 @@ describe('NgSnotify Testing', () => {
});

it('should create toasts at different positions', (done) => {
const fixture = TestBed.createComponent(AppComponent);
const app = fixture.debugElement.componentInstance;
const service: SnotifyService = fixture.debugElement.injector.get(SnotifyService);
fixture.detectChanges();
const compiled = fixture.debugElement.nativeElement;
Expand Down
2 changes: 1 addition & 1 deletion gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ gulp.task('copy:manifest', function () {
* 9. Copy README.md from / to /dist
*/
gulp.task('copy:readme', function () {
return gulp.src([path.join(rootFolder, 'README.MD')])
return gulp.src([path.join(rootFolder, 'README.md')])
.pipe(gulp.dest(distFolder));
});

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"compodoc:serve": "npm run compodoc:build -- -s",
"compodoc:watch": "npm run compodoc:build -- -s -w",
"lint": "tslint --type-check -p src/tsconfig.es5.json src/**/*.ts",
"test": "npm run link:dist && tsc && karma start --single-run",
"test": "npm run link:dist && ng test",
"lib:lint": "npm run lint && npm run example:lint",
"lib:build": "npm run lib:lint && npm run build",
"docs:build": "gitbook build ./docs ./demo/documentation",
Expand Down

0 comments on commit 918a4e8

Please sign in to comment.