diff --git a/src/toasty.component.ts b/src/toasty.component.ts
index 7a600f5..b4fa8d9 100644
--- a/src/toasty.component.ts
+++ b/src/toasty.component.ts
@@ -11,7 +11,7 @@ import { ToastyService, ToastData, ToastyConfig } from './toasty.service';
* Toasty is container for Toast components
*/
@Component({
- moduleId: module.id,
+ moduleId: module.id.toString(),
selector: 'ng2-toasty',
template: `
diff --git a/systemjs.config.js b/systemjs.config.js
new file mode 100644
index 0000000..7e535ac
--- /dev/null
+++ b/systemjs.config.js
@@ -0,0 +1,39 @@
+/**
+ * System configuration for Angular 2.
+ */
+(function (global) {
+ System.config({
+ paths: {
+ // paths serve as alias
+ 'npm:': 'node_modules/'
+ },
+ // map tells the System loader where to look for things
+ map: {
+ // our app is within the app folder
+ app: '.',
+
+ // angular bundles
+ '@angular/core': 'npm:@angular/core/bundles/core.umd.js',
+ '@angular/common': 'npm:@angular/common/bundles/common.umd.js',
+ '@angular/compiler': 'npm:@angular/compiler/bundles/compiler.umd.js',
+ '@angular/platform-browser': 'npm:@angular/platform-browser/bundles/platform-browser.umd.js',
+ '@angular/platform-browser-dynamic': 'npm:@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.js',
+ '@angular/http': 'npm:@angular/http/bundles/http.umd.js',
+ '@angular/router': 'npm:@angular/router/bundles/router.umd.js',
+ '@angular/forms': 'npm:@angular/forms/bundles/forms.umd.js',
+
+ // other libraries
+ 'rxjs': 'npm:rxjs'
+ },
+ // packages tells the System loader how to load when no filename and/or no extension
+ packages: {
+ app: {
+ main: './index.js',
+ defaultExtension: 'js'
+ },
+ rxjs: {
+ defaultExtension: 'js'
+ }
+ }
+ });
+})(this);
\ No newline at end of file
diff --git a/tests/toast.component.spec.ts b/tests/toast.component.spec.ts
index 0b1771b..1ee0e14 100644
--- a/tests/toast.component.spec.ts
+++ b/tests/toast.component.spec.ts
@@ -1,121 +1,111 @@
-import { inject, async, tick, TestBed, ComponentFixture }
+import { TestBed, ComponentFixture }
from '@angular/core/testing';
-import {
- BrowserDynamicTestingModule, platformBrowserDynamicTesting
-} from '@angular/platform-browser-dynamic/testing';
-
import {ToastData} from '../src/toasty.service';
import {ToastComponent} from '../src/toast.component';
-TestBed.resetTestEnvironment();
-TestBed.initTestEnvironment(
- BrowserDynamicTestingModule, platformBrowserDynamicTesting());
-
-export function main() {
- describe('ToastComponent', () => {
-
- let componentFixture:ComponentFixture;
-
- const toast:ToastData = {
- id:1,
- title:null,
- msg:null,
- showClose:false,
- type: 'toasty-type-default',
- theme:'toasty-theme-default',
- timeout: null,
- onAdd: null,
- onRemove:null,
- onClick:null
- };
-
- beforeEach(() => {
- TestBed.configureTestingModule({
- declarations: [ToastComponent]
- });
- TestBed.compileComponents();
+describe('ToastComponent', () => {
+
+ let componentFixture:ComponentFixture;
+
+ const toast:ToastData = {
+ id:1,
+ title:null,
+ msg:null,
+ showClose:false,
+ type: 'toasty-type-default',
+ theme:'toasty-theme-default',
+ timeout: null,
+ onAdd: null,
+ onRemove:null,
+ onClick:null
+ };
+
+ beforeEach(() => {
+ TestBed.configureTestingModule({
+ declarations: [ToastComponent]
});
+ TestBed.compileComponents();
+ });
- beforeEach(() => {
- componentFixture = TestBed.createComponent(ToastComponent);
- componentFixture.componentInstance.toast = toast;
- componentFixture.detectChanges();
- });
+ beforeEach(() => {
+ componentFixture = TestBed.createComponent(ToastComponent);
+ componentFixture.componentInstance.toast = toast;
+ componentFixture.detectChanges();
+ });
- it('should be defined', () => {
- const element = componentFixture.elementRef.nativeElement;
- expect(element.querySelector('.toast')).toBeDefined();
- });
+ it('should be defined', () => {
+ const element = componentFixture.elementRef.nativeElement;
+ expect(element.querySelector('.toast')).toBeDefined();
+ });
- it('should has all classes', () => {
- const element = componentFixture.nativeElement;
- let className:string = element.querySelector('.toast').className;
- expect(className.indexOf('toast')).toBeGreaterThan(-1);
- expect(className.indexOf('toasty-type-default')).toBeGreaterThan(-1);
- expect(className.indexOf('toasty-theme-default')).toBeGreaterThan(-1);
- });
+ it('should has all classes', () => {
+ const element = componentFixture.nativeElement;
+ let className:string = element.querySelector('.toast').className;
+ expect(className.indexOf('toast')).toBeGreaterThan(-1);
+ expect(className.indexOf('toasty-type-default')).toBeGreaterThan(-1);
+ expect(className.indexOf('toasty-theme-default')).toBeGreaterThan(-1);
+ });
- it('should show close button', () => {
- const element = componentFixture.nativeElement;
- expect(element.querySelector('.close-button')).toBeNull();
+ it('should show close button', () => {
+ const element = componentFixture.nativeElement;
+ expect(element.querySelector('.close-button')).toBeNull();
- componentFixture.componentInstance.toast.showClose = true;
- componentFixture.detectChanges();
- expect(element.querySelector('.close-button')).not.toBeNull();
- });
+ componentFixture.componentInstance.toast.showClose = true;
+ componentFixture.detectChanges();
+ expect(element.querySelector('.close-button')).not.toBeNull();
+ });
- it('should show only title', () => {
- const element = componentFixture.nativeElement;
- expect(element.querySelector('.toast-text')).toBeNull();
+ it('should show only title', () => {
+ const element = componentFixture.nativeElement;
+ expect(element.querySelector('.toast-text')).toBeNull();
- componentFixture.componentInstance.toast.title = 'title';
- componentFixture.detectChanges();
- expect(element.querySelector('.toast-text')).not.toBeNull();
+ componentFixture.componentInstance.toast.title = 'title';
+ componentFixture.detectChanges();
+ expect(element.querySelector('.toast-text')).not.toBeNull();
- expect(element.querySelector('.toast-title')).not.toBeNull();
- expect(element.querySelector('.toast-title').innerHTML).toBe('title');
+ expect(element.querySelector('.toast-title')).not.toBeNull();
+ expect(element.querySelector('.toast-title').innerHTML).toBe('title');
- expect(element.querySelector('.toast-msg')).toBeNull();
+ expect(element.querySelector('.toast-msg')).toBeNull();
- componentFixture.componentInstance.toast.title = null;
- componentFixture.componentInstance.toast.msg = null;
- });
+ componentFixture.componentInstance.toast.title = null;
+ componentFixture.componentInstance.toast.msg = null;
+ });
- it('should show only message', () => {
- const element = componentFixture.nativeElement;
- expect(element.querySelector('.toast-text')).toBeNull();
+ it('should show only message', () => {
+ const element = componentFixture.nativeElement;
+ expect(element.querySelector('.toast-text')).toBeNull();
- componentFixture.componentInstance.toast.msg = 'msg';
- componentFixture.detectChanges();
- expect(element.querySelector('.toast-text')).not.toBeNull();
+ componentFixture.componentInstance.toast.msg = 'msg';
+ componentFixture.detectChanges();
+ expect(element.querySelector('.toast-text')).not.toBeNull();
- expect(element.querySelector('.toast-title')).toBeNull();
+ expect(element.querySelector('.toast-title')).toBeNull();
- expect(element.querySelector('.toast-msg')).not.toBeNull();
- expect(element.querySelector('.toast-msg').innerHTML).toBe('msg');
+ expect(element.querySelector('.toast-msg')).not.toBeNull();
+ expect(element.querySelector('.toast-msg').innerHTML).toBe('msg');
- componentFixture.componentInstance.toast.title = null;
- componentFixture.componentInstance.toast.msg = null;
- });
+ componentFixture.componentInstance.toast.title = null;
+ componentFixture.componentInstance.toast.msg = null;
+ });
- it('should show title and message', () => {
- const element = componentFixture.nativeElement;
- expect(element.querySelector('.toast-text')).toBeNull();
+ it('should show title and message', () => {
+ const element = componentFixture.nativeElement;
+ expect(element.querySelector('.toast-text')).toBeNull();
- componentFixture.componentInstance.toast.title = 'title';
- componentFixture.componentInstance.toast.msg = 'msg';
- componentFixture.detectChanges();
- expect(element.querySelector('.toast-text')).not.toBeNull();
+ componentFixture.componentInstance.toast.title = 'title';
+ componentFixture.componentInstance.toast.msg = 'msg';
+ componentFixture.detectChanges();
+ expect(element.querySelector('.toast-text')).not.toBeNull();
- expect(element.querySelector('.toast-title')).not.toBeNull();
- expect(element.querySelector('.toast-title').innerHTML).toBe('title');
+ expect(element.querySelector('.toast-title')).not.toBeNull();
+ expect(element.querySelector('.toast-title').innerHTML).toBe('title');
- expect(element.querySelector('.toast-msg')).not.toBeNull();
- expect(element.querySelector('.toast-msg').innerHTML).toBe('msg');
+ expect(element.querySelector('.toast-msg')).not.toBeNull();
+ expect(element.querySelector('.toast-msg').innerHTML).toBe('msg');
- componentFixture.componentInstance.toast.title = null;
- componentFixture.componentInstance.toast.msg = null;
- });
+ componentFixture.componentInstance.toast.title = null;
+ componentFixture.componentInstance.toast.msg = null;
});
-}
\ No newline at end of file
+});
diff --git a/tests/toasty.component.spec.ts b/tests/toasty.component.spec.ts
index dfe79db..6aa6684 100644
--- a/tests/toasty.component.spec.ts
+++ b/tests/toasty.component.spec.ts
@@ -1,180 +1,171 @@
-import { inject, async, tick, TestBed, ComponentFixture }
+import { TestBed, ComponentFixture }
from '@angular/core/testing';
-import {
- BrowserDynamicTestingModule, platformBrowserDynamicTesting
-} from '@angular/platform-browser-dynamic/testing';
-
import {ToastyService, ToastData, ToastOptions, ToastyConfig} from '../src/toasty.service';
import {ToastyComponent} from '../src/toasty.component';
-
-TestBed.resetTestEnvironment();
-TestBed.initTestEnvironment(
- BrowserDynamicTestingModule, platformBrowserDynamicTesting());
-
-export function main() {
- describe('ToastyComponent', () => {
-
- let componentFixture:ComponentFixture;
-
- const toast1:ToastData = {
- id:1,
- title:'title1',
- msg:'message1',
- showClose:false,
- type: 'toasty-type-default',
- theme:'toasty-theme-default',
- timeout: null,
- onAdd: null,
- onRemove:null,
- onClick:null
- };
-
- const toast2:ToastData = {
- id:2,
- title:'title2',
- msg:'message2',
- showClose:false,
- type: 'toasty-type-default',
- theme:'toasty-theme-default',
- timeout: null,
- onAdd: null,
- onRemove:null,
- onClick:null
- };
-
- beforeEach(() => {
- TestBed.configureTestingModule({
- declarations: [ToastyComponent],
- providers: [ToastyService, ToastyConfig]
- });
- TestBed.compileComponents();
+import {ToastComponent} from '../src/toast.component';
+
+describe('ToastyComponent', () => {
+
+ let componentFixture:ComponentFixture;
+
+ const toast1:ToastData = {
+ id:1,
+ title:'title1',
+ msg:'message1',
+ showClose:false,
+ type: 'toasty-type-default',
+ theme:'toasty-theme-default',
+ timeout: null,
+ onAdd: null,
+ onRemove:null,
+ onClick:null
+ };
+
+ const toast2:ToastData = {
+ id:2,
+ title:'title2',
+ msg:'message2',
+ showClose:false,
+ type: 'toasty-type-default',
+ theme:'toasty-theme-default',
+ timeout: null,
+ onAdd: null,
+ onRemove:null,
+ onClick:null
+ };
+
+ beforeEach(() => {
+ TestBed.configureTestingModule({
+ declarations: [ToastComponent, ToastyComponent],
+ providers: [ToastyService, ToastyConfig]
});
+ TestBed.compileComponents();
+ });
- beforeEach(() => {
- componentFixture = TestBed.createComponent(ToastyComponent);
- componentFixture.detectChanges();
- });
-
- it('should be defined', () => {
- const element = componentFixture.elementRef.nativeElement;
- expect(element.querySelector('#toasty')).toBeDefined();
- });
+ beforeEach(() => {
+ componentFixture = TestBed.createComponent(ToastyComponent);
+ componentFixture.detectChanges();
+ });
- it('should update class if position property was not defined', () => {
- const element = componentFixture.nativeElement;
- componentFixture.detectChanges();
- expect(element.querySelector('#toasty').className).toBe('toasty-position-bottom-right');
- });
+ it('should be defined', () => {
+ const element = componentFixture.elementRef.nativeElement;
+ expect(element.querySelector('#toasty')).toBeDefined();
+ });
- it('should update class if position property was defined with wrong value', () => {
- const element = componentFixture.nativeElement;
- componentFixture.componentInstance.position = 'left';
- componentFixture.detectChanges();
- expect(element.querySelector('#toasty').className).toBe('toasty-position-bottom-right');
- });
+ it('should update class if position property was not defined', () => {
+ const element = componentFixture.nativeElement;
+ componentFixture.detectChanges();
+ expect(element.querySelector('#toasty').className).toBe('toasty-position-bottom-right');
+ });
- it('should update class if position property was defined with right value', () => {
- const element = componentFixture.nativeElement;
- componentFixture.componentInstance.position = 'bottom-center';
- componentFixture.detectChanges();
- expect(element.querySelector('#toasty').className).toBe('toasty-position-bottom-center');
- });
+ it('should update class if position property was defined with wrong value', () => {
+ const element = componentFixture.nativeElement;
+ componentFixture.componentInstance.position = 'left';
+ componentFixture.detectChanges();
+ expect(element.querySelector('#toasty').className).toBe('toasty-position-bottom-right');
+ });
- it('should provide the child toast component if it was created via service', () => {
- const element = componentFixture.nativeElement;
- expect(componentFixture.componentInstance.toasts.length).toBe(0);
- expect(element.querySelector('#toasty').children.length).toBe(0);
+ it('should update class if position property was defined with right value', () => {
+ const element = componentFixture.nativeElement;
+ componentFixture.componentInstance.position = 'bottom-center';
+ componentFixture.detectChanges();
+ expect(element.querySelector('#toasty').className).toBe('toasty-position-bottom-center');
+ });
- componentFixture.componentInstance.toasts.push(toast1);
- componentFixture.detectChanges();
- expect(element.querySelector('#toasty').children.length).toBe(1);
- expect(element.querySelector('#toasty').children[0].tagName).toBe('NG2-TOAST');
- });
+ it('should provide the child toast component if it was created via service', () => {
+ const element = componentFixture.nativeElement;
+ expect(componentFixture.componentInstance.toasts.length).toBe(0);
+ expect(element.querySelector('#toasty').children.length).toBe(0);
- it('should clear specific toast by id', () => {
- const element = componentFixture.nativeElement;
- componentFixture.componentInstance.toasts.push(toast1);
- componentFixture.componentInstance.toasts.push(toast2);
- componentFixture.detectChanges();
- expect(element.querySelector('#toasty').children.length).toBe(2);
+ componentFixture.componentInstance.toasts.push(toast1);
+ componentFixture.detectChanges();
+ expect(element.querySelector('#toasty').children.length).toBe(1);
+ expect(element.querySelector('#toasty').children[0].tagName).toBe('NG2-TOAST');
+ });
- componentFixture.componentInstance.clear(1);
- componentFixture.detectChanges();
- expect(element.querySelector('#toasty').children.length).toBe(1);
- });
+ it('should clear specific toast by id', () => {
+ const element = componentFixture.nativeElement;
+ componentFixture.componentInstance.toasts.push(toast1);
+ componentFixture.componentInstance.toasts.push(toast2);
+ componentFixture.detectChanges();
+ expect(element.querySelector('#toasty').children.length).toBe(2);
- it('should clear all toasts', () => {
- const element = componentFixture.nativeElement;
- componentFixture.componentInstance.toasts.push(toast1);
- componentFixture.componentInstance.toasts.push(toast2);
- componentFixture.detectChanges();
- expect(element.querySelector('#toasty').children.length).toBe(2);
+ componentFixture.componentInstance.clear(1);
+ componentFixture.detectChanges();
+ expect(element.querySelector('#toasty').children.length).toBe(1);
+ });
- componentFixture.componentInstance.clearAll();
- componentFixture.detectChanges();
- expect(element.querySelector('#toasty').children.length).toBe(0);
- });
+ it('should clear all toasts', () => {
+ const element = componentFixture.nativeElement;
+ componentFixture.componentInstance.toasts.push(toast1);
+ componentFixture.componentInstance.toasts.push(toast2);
+ componentFixture.detectChanges();
+ expect(element.querySelector('#toasty').children.length).toBe(2);
- it('should call onRemove when clear specific toast by id', () => {
- const element = componentFixture.nativeElement;
- toast1.onRemove = (toast:ToastData) => {
- expect(toast).toBe(toast1);
- };
- componentFixture.componentInstance.toasts.push(toast1);
- componentFixture.componentInstance.toasts.push(toast2);
- componentFixture.detectChanges();
- expect(element.querySelector('#toasty').children.length).toBe(2);
-
- componentFixture.componentInstance.clear(1);
- componentFixture.detectChanges();
- expect(element.querySelector('#toasty').children.length).toBe(1);
- });
+ componentFixture.componentInstance.clearAll();
+ componentFixture.detectChanges();
+ expect(element.querySelector('#toasty').children.length).toBe(0);
+ });
- it('should clear toast by closeToast method', () => {
- const element = componentFixture.nativeElement;
- toast1.onRemove = (toast:ToastData) => {
- expect(toast).toBe(toast1);
- };
- componentFixture.componentInstance.toasts.push(toast1);
- componentFixture.componentInstance.toasts.push(toast2);
- componentFixture.detectChanges();
- expect(element.querySelector('#toasty').children.length).toBe(2);
-
- componentFixture.componentInstance.closeToast(toast1);
- componentFixture.detectChanges();
- expect(element.querySelector('#toasty').children.length).toBe(1);
- });
+ it('should call onRemove when clear specific toast by id', () => {
+ const element = componentFixture.nativeElement;
+ toast1.onRemove = (toast:ToastData) => {
+ expect(toast).toBe(toast1);
+ };
+ componentFixture.componentInstance.toasts.push(toast1);
+ componentFixture.componentInstance.toasts.push(toast2);
+ componentFixture.detectChanges();
+ expect(element.querySelector('#toasty').children.length).toBe(2);
+
+ componentFixture.componentInstance.clear(1);
+ componentFixture.detectChanges();
+ expect(element.querySelector('#toasty').children.length).toBe(1);
+ });
- // describe('work with timeout', () => {
-
- // function createComponent(tcb: TestComponentBuilder): Promise {
- // return tcb.createAsync(ToastyContainer).then((cf:ComponentFixture) => {
- // cf.detectChanges();
- // return cf;
- // });
- // }
-
- // it('should close toast after timeout', inject([TestComponentBuilder],
- // fakeAsync((tcb:TestComponentBuilder) => {
- // createComponent(tcb).then((fixture:ComponentFixture) => {
- // const element = fixture.nativeElement;
- // toast1.onRemove = (toast:Toast) => {
- // expect(toast).toBe(toast1);
- // };
- // toast1.timeout = 1000;
- // fixture.componentInstance.toasts.push(toast1);
- // fixture.componentInstance.toasts.push(toast2);
- // fixture.detectChanges();
- // expect(element.querySelector('#toasty').children.length).toBe(2);
- // tick();
-
- // fixture.detectChanges();
- // expect(element.querySelector('#toasty').children.length).toBe(1);
- // });
- // })
- // ));
- // });
+ it('should clear toast by closeToast method', () => {
+ const element = componentFixture.nativeElement;
+ toast1.onRemove = (toast:ToastData) => {
+ expect(toast).toBe(toast1);
+ };
+ componentFixture.componentInstance.toasts.push(toast1);
+ componentFixture.componentInstance.toasts.push(toast2);
+ componentFixture.detectChanges();
+ expect(element.querySelector('#toasty').children.length).toBe(2);
+
+ componentFixture.componentInstance.closeToast(toast1);
+ componentFixture.detectChanges();
+ expect(element.querySelector('#toasty').children.length).toBe(1);
});
-}
\ No newline at end of file
+
+ // describe('work with timeout', () => {
+
+ // function createComponent(tcb: TestComponentBuilder): Promise {
+ // return tcb.createAsync(ToastyContainer).then((cf:ComponentFixture) => {
+ // cf.detectChanges();
+ // return cf;
+ // });
+ // }
+
+ // it('should close toast after timeout', inject([TestComponentBuilder],
+ // fakeAsync((tcb:TestComponentBuilder) => {
+ // createComponent(tcb).then((fixture:ComponentFixture) => {
+ // const element = fixture.nativeElement;
+ // toast1.onRemove = (toast:Toast) => {
+ // expect(toast).toBe(toast1);
+ // };
+ // toast1.timeout = 1000;
+ // fixture.componentInstance.toasts.push(toast1);
+ // fixture.componentInstance.toasts.push(toast2);
+ // fixture.detectChanges();
+ // expect(element.querySelector('#toasty').children.length).toBe(2);
+ // tick();
+
+ // fixture.detectChanges();
+ // expect(element.querySelector('#toasty').children.length).toBe(1);
+ // });
+ // })
+ // ));
+ // });
+});
diff --git a/tests/toasty.service.spec.ts b/tests/toasty.service.spec.ts
index 27c74df..55c2d67 100644
--- a/tests/toasty.service.spec.ts
+++ b/tests/toasty.service.spec.ts
@@ -1,264 +1,255 @@
import { inject, fakeAsync, tick, TestBed }
from '@angular/core/testing';
-import { BrowserDynamicTestingModule, platformBrowserDynamicTesting }
- from '@angular/platform-browser-dynamic/testing';
-
import {Observable} from 'rxjs/Observable';
import {ToastyService, ToastData, ToastOptions, ToastyConfig} from '../src/toasty.service';
-TestBed.resetTestEnvironment();
-TestBed.initTestEnvironment(
- BrowserDynamicTestingModule, platformBrowserDynamicTesting());
-
-export function main() {
- describe('ToastyService', () => {
+describe('ToastyService', () => {
- beforeEach(() => {
- TestBed.configureTestingModule({
- providers: [ToastyService, ToastyConfig]
- });
+ beforeEach(() => {
+ TestBed.configureTestingModule({
+ providers: [ToastyService, ToastyConfig]
});
+ });
+
+ it('is defined',
+ inject([ToastyService], (service:ToastyService) => {
+ expect(ToastyService).toBeDefined();
+ expect(service instanceof ToastyService).toBeTruthy();
+ })
+ );
+
+ it('should return Observable from getToasts method',
+ inject([ToastyService], (service:ToastyService) => {
+ expect(service.getToasts instanceof Observable);
+ })
+ );
+
+ describe('create default toasty', () => {
- it('is defined',
+ it('with string title',
inject([ToastyService], (service:ToastyService) => {
- expect(ToastyService).toBeDefined();
- expect(service instanceof ToastyService).toBeTruthy();
+ // We listen our service to recieve new toasts from it
+ service.getToasts().subscribe((toast:ToastData) => {
+ expect(toast).not.toBeNull();
+ expect(toast.id).not.toBeNull();
+ expect(toast.title).toBe('Hi');
+ expect(toast.msg).not.toBeDefined();
+ expect(toast.showClose).toBe(true);
+ expect(toast.type).toBe('toasty-type-default');
+ expect(toast.theme).toBe('toasty-theme-default');
+ expect(toast.onAdd).toBeNull();
+ expect(toast.onRemove).toBeNull();
+ });
+ service.default('Hi');
})
);
- it('should return Observable from getToasts method',
+ it('with number title',
inject([ToastyService], (service:ToastyService) => {
- expect(service.getToasts instanceof Observable);
+ // We listen our service to recieve new toasts from it
+ service.getToasts().subscribe((toast:ToastData) => {
+ expect(toast).not.toBeNull();
+ expect(toast.id).not.toBeNull();
+ expect(toast.title).toBe('1000');
+ expect(toast.msg).not.toBeDefined();
+ expect(toast.showClose).toBe(true);
+ expect(toast.type).toBe('toasty-type-default');
+ expect(toast.theme).toBe('toasty-theme-default');
+ expect(toast.onAdd).toBeNull();
+ expect(toast.onRemove).toBeNull();
+ });
+ service.default(1000);
})
);
- describe('create default toasty', () => {
-
- it('with string title',
- inject([ToastyService], (service:ToastyService) => {
- // We listen our service to recieve new toasts from it
- service.getToasts().subscribe((toast:ToastData) => {
- expect(toast).not.toBeNull();
- expect(toast.id).not.toBeNull();
- expect(toast.title).toBe('Hi');
- expect(toast.msg).not.toBeDefined();
- expect(toast.showClose).toBe(true);
- expect(toast.type).toBe('toasty-type-default');
- expect(toast.theme).toBe('toasty-theme-default');
- expect(toast.onAdd).toBeNull();
- expect(toast.onRemove).toBeNull();
- });
- service.default('Hi');
- })
- );
-
- it('with number title',
- inject([ToastyService], (service:ToastyService) => {
- // We listen our service to recieve new toasts from it
- service.getToasts().subscribe((toast:ToastData) => {
- expect(toast).not.toBeNull();
- expect(toast.id).not.toBeNull();
- expect(toast.title).toBe('1000');
- expect(toast.msg).not.toBeDefined();
- expect(toast.showClose).toBe(true);
- expect(toast.type).toBe('toasty-type-default');
- expect(toast.theme).toBe('toasty-theme-default');
- expect(toast.onAdd).toBeNull();
- expect(toast.onRemove).toBeNull();
- });
- service.default(1000);
- })
- );
+ it('with ToastyOptions',
+ inject([ToastyService], (service:ToastyService) => {
+ // Create options
+ var options:ToastOptions = {
+ title: 'Title',
+ msg: 'message',
+ };
+ // We listen our service to recieve new toasts from it
+ service.getToasts().subscribe((toast:ToastData) => {
+ expect(toast).not.toBeNull();
+ expect(toast.id).not.toBeNull();
+ expect(toast.title).toBe(options.title);
+ expect(toast.msg).toBe(options.msg);
+ expect(toast.showClose).toBe(true);
+ expect(toast.type).toBe('toasty-type-default');
+ expect(toast.theme).toBe('toasty-theme-default');
+ expect(toast.onAdd).toBeNull();
+ expect(toast.onRemove).toBeNull();
+ });
+ service.default(options);
+ })
+ );
- it('with ToastyOptions',
- inject([ToastyService], (service:ToastyService) => {
- // Create options
- var options:ToastOptions = {
- title: 'Title',
- msg: 'message',
- };
- // We listen our service to recieve new toasts from it
- service.getToasts().subscribe((toast:ToastData) => {
- expect(toast).not.toBeNull();
+ it('and call onAdd function',
+ inject([ToastyService], (service:ToastyService) => {
+ // Create options
+ var options:ToastOptions = {
+ title: 'Title',
+ msg: 'message',
+ onAdd: (toast:ToastData) => {
+ expect(toast).toBeDefined();
expect(toast.id).not.toBeNull();
expect(toast.title).toBe(options.title);
expect(toast.msg).toBe(options.msg);
expect(toast.showClose).toBe(true);
expect(toast.type).toBe('toasty-type-default');
expect(toast.theme).toBe('toasty-theme-default');
- expect(toast.onAdd).toBeNull();
+ expect(toast.onAdd).not.toBeNull();
expect(toast.onRemove).toBeNull();
- });
- service.default(options);
- })
- );
-
- it('and call onAdd function',
- inject([ToastyService], (service:ToastyService) => {
- // Create options
- var options:ToastOptions = {
- title: 'Title',
- msg: 'message',
- onAdd: (toast:ToastData) => {
- expect(toast).toBeDefined();
- expect(toast.id).not.toBeNull();
- expect(toast.title).toBe(options.title);
- expect(toast.msg).toBe(options.msg);
- expect(toast.showClose).toBe(true);
- expect(toast.type).toBe('toasty-type-default');
- expect(toast.theme).toBe('toasty-theme-default');
- expect(toast.onAdd).not.toBeNull();
- expect(toast.onRemove).toBeNull();
- }
- };
- // We listen our service to recieve new toasts from it
- service.getToasts().subscribe((toast:ToastData) => {});
- service.default(options);
- })
- );
- });
+ }
+ };
+ // We listen our service to recieve new toasts from it
+ service.getToasts().subscribe((toast:ToastData) => {});
+ service.default(options);
+ })
+ );
+ });
- describe('create toasty', () => {
- it('of info type',
- inject([ToastyService], (service:ToastyService) => {
- // We listen our service to recieve new toasts from it
- service.getToasts().subscribe((toast:ToastData) => {
- expect(toast).not.toBeNull();
- expect(toast.id).not.toBeNull();
- expect(toast.title).toBe('Hi');
- expect(toast.msg).not.toBeDefined();
- expect(toast.showClose).toBe(true);
- expect(toast.type).toBe('toasty-type-info');
- expect(toast.theme).toBe('toasty-theme-default');
- expect(toast.onAdd).toBeNull();
- expect(toast.onRemove).toBeNull();
- });
- service.info('Hi');
- })
- );
+ describe('create toasty', () => {
+ it('of info type',
+ inject([ToastyService], (service:ToastyService) => {
+ // We listen our service to recieve new toasts from it
+ service.getToasts().subscribe((toast:ToastData) => {
+ expect(toast).not.toBeNull();
+ expect(toast.id).not.toBeNull();
+ expect(toast.title).toBe('Hi');
+ expect(toast.msg).not.toBeDefined();
+ expect(toast.showClose).toBe(true);
+ expect(toast.type).toBe('toasty-type-info');
+ expect(toast.theme).toBe('toasty-theme-default');
+ expect(toast.onAdd).toBeNull();
+ expect(toast.onRemove).toBeNull();
+ });
+ service.info('Hi');
+ })
+ );
- it('of success type',
- inject([ToastyService], (service:ToastyService) => {
- // We listen our service to recieve new toasts from it
- service.getToasts().subscribe((toast:ToastData) => {
- expect(toast).not.toBeNull();
- expect(toast.id).not.toBeNull();
- expect(toast.title).toBe('Hi');
- expect(toast.msg).not.toBeDefined();
- expect(toast.showClose).toBe(true);
- expect(toast.type).toBe('toasty-type-success');
- expect(toast.theme).toBe('toasty-theme-default');
- expect(toast.onAdd).toBeNull();
- expect(toast.onRemove).toBeNull();
- });
- service.success('Hi');
- })
- );
+ it('of success type',
+ inject([ToastyService], (service:ToastyService) => {
+ // We listen our service to recieve new toasts from it
+ service.getToasts().subscribe((toast:ToastData) => {
+ expect(toast).not.toBeNull();
+ expect(toast.id).not.toBeNull();
+ expect(toast.title).toBe('Hi');
+ expect(toast.msg).not.toBeDefined();
+ expect(toast.showClose).toBe(true);
+ expect(toast.type).toBe('toasty-type-success');
+ expect(toast.theme).toBe('toasty-theme-default');
+ expect(toast.onAdd).toBeNull();
+ expect(toast.onRemove).toBeNull();
+ });
+ service.success('Hi');
+ })
+ );
- it('of wait type',
- inject([ToastyService], (service:ToastyService) => {
- // We listen our service to recieve new toasts from it
- service.getToasts().subscribe((toast:ToastData) => {
- expect(toast).not.toBeNull();
- expect(toast.id).not.toBeNull();
- expect(toast.title).toBe('Hi');
- expect(toast.msg).not.toBeDefined();
- expect(toast.showClose).toBe(true);
- expect(toast.type).toBe('toasty-type-wait');
- expect(toast.theme).toBe('toasty-theme-default');
- expect(toast.onAdd).toBeNull();
- expect(toast.onRemove).toBeNull();
- });
- service.wait('Hi');
- })
- );
+ it('of wait type',
+ inject([ToastyService], (service:ToastyService) => {
+ // We listen our service to recieve new toasts from it
+ service.getToasts().subscribe((toast:ToastData) => {
+ expect(toast).not.toBeNull();
+ expect(toast.id).not.toBeNull();
+ expect(toast.title).toBe('Hi');
+ expect(toast.msg).not.toBeDefined();
+ expect(toast.showClose).toBe(true);
+ expect(toast.type).toBe('toasty-type-wait');
+ expect(toast.theme).toBe('toasty-theme-default');
+ expect(toast.onAdd).toBeNull();
+ expect(toast.onRemove).toBeNull();
+ });
+ service.wait('Hi');
+ })
+ );
- it('of error type',
- inject([ToastyService], (service:ToastyService) => {
- // We listen our service to recieve new toasts from it
- service.getToasts().subscribe((toast:ToastData) => {
- expect(toast).not.toBeNull();
- expect(toast.id).not.toBeNull();
- expect(toast.title).toBe('Hi');
- expect(toast.msg).not.toBeDefined();
- expect(toast.showClose).toBe(true);
- expect(toast.type).toBe('toasty-type-error');
- expect(toast.theme).toBe('toasty-theme-default');
- expect(toast.onAdd).toBeNull();
- expect(toast.onRemove).toBeNull();
- });
- service.error('Hi');
- })
- );
+ it('of error type',
+ inject([ToastyService], (service:ToastyService) => {
+ // We listen our service to recieve new toasts from it
+ service.getToasts().subscribe((toast:ToastData) => {
+ expect(toast).not.toBeNull();
+ expect(toast.id).not.toBeNull();
+ expect(toast.title).toBe('Hi');
+ expect(toast.msg).not.toBeDefined();
+ expect(toast.showClose).toBe(true);
+ expect(toast.type).toBe('toasty-type-error');
+ expect(toast.theme).toBe('toasty-theme-default');
+ expect(toast.onAdd).toBeNull();
+ expect(toast.onRemove).toBeNull();
+ });
+ service.error('Hi');
+ })
+ );
- it('of warning type',
- inject([ToastyService], (service:ToastyService) => {
- // We listen our service to recieve new toasts from it
- service.getToasts().subscribe((toast:ToastData) => {
- expect(toast).not.toBeNull();
- expect(toast.id).not.toBeNull();
- expect(toast.title).toBe('Hi');
- expect(toast.msg).not.toBeDefined();
- expect(toast.showClose).toBe(true);
- expect(toast.type).toBe('toasty-type-warning');
- expect(toast.theme).toBe('toasty-theme-default');
- expect(toast.onAdd).toBeNull();
- expect(toast.onRemove).toBeNull();
- });
- service.warning('Hi');
- })
- );
- });
+ it('of warning type',
+ inject([ToastyService], (service:ToastyService) => {
+ // We listen our service to recieve new toasts from it
+ service.getToasts().subscribe((toast:ToastData) => {
+ expect(toast).not.toBeNull();
+ expect(toast.id).not.toBeNull();
+ expect(toast.title).toBe('Hi');
+ expect(toast.msg).not.toBeDefined();
+ expect(toast.showClose).toBe(true);
+ expect(toast.type).toBe('toasty-type-warning');
+ expect(toast.theme).toBe('toasty-theme-default');
+ expect(toast.onAdd).toBeNull();
+ expect(toast.onRemove).toBeNull();
+ });
+ service.warning('Hi');
+ })
+ );
+ });
- describe('create toasty', () => {
- it('of material theme',
- inject([ToastyService], (service:ToastyService) => {
- var options:ToastOptions = {
- title: 'Title',
- msg: 'message',
- theme: 'material'
- }
- // We listen our service to recieve new toasts from it
- service.getToasts().subscribe((toast:ToastData) => {
- expect(toast).not.toBeNull();
- expect(toast.id).not.toBeNull();
- expect(toast.title).toBe(options.title);
- expect(toast.msg).toBe(options.msg);
- expect(toast.showClose).toBe(true);
- expect(toast.type).toBe('toasty-type-default');
- expect(toast.theme).toBe('toasty-theme-material');
- expect(toast.onAdd).toBeNull();
- expect(toast.onRemove).toBeNull();
- });
- service.default(options);
- })
- );
+ describe('create toasty', () => {
+ it('of material theme',
+ inject([ToastyService], (service:ToastyService) => {
+ var options:ToastOptions = {
+ title: 'Title',
+ msg: 'message',
+ theme: 'material'
+ }
+ // We listen our service to recieve new toasts from it
+ service.getToasts().subscribe((toast:ToastData) => {
+ expect(toast).not.toBeNull();
+ expect(toast.id).not.toBeNull();
+ expect(toast.title).toBe(options.title);
+ expect(toast.msg).toBe(options.msg);
+ expect(toast.showClose).toBe(true);
+ expect(toast.type).toBe('toasty-type-default');
+ expect(toast.theme).toBe('toasty-theme-material');
+ expect(toast.onAdd).toBeNull();
+ expect(toast.onRemove).toBeNull();
+ });
+ service.default(options);
+ })
+ );
- it('of bootstrap theme',
- inject([ToastyService], (service:ToastyService) => {
- var options:ToastOptions = {
- title: 'Title',
- msg: 'message',
- theme: 'bootstrap'
- }
- // We listen our service to recieve new toasts from it
- service.getToasts().subscribe((toast:ToastData) => {
- expect(toast).not.toBeNull();
- expect(toast.id).not.toBeNull();
- expect(toast.title).toBe(options.title);
- expect(toast.msg).toBe(options.msg);
- expect(toast.showClose).toBe(true);
- expect(toast.type).toBe('toasty-type-default');
- expect(toast.theme).toBe('toasty-theme-bootstrap');
- expect(toast.onAdd).toBeNull();
- expect(toast.onRemove).toBeNull();
- });
- service.default(options);
- })
- );
- });
+ it('of bootstrap theme',
+ inject([ToastyService], (service:ToastyService) => {
+ var options:ToastOptions = {
+ title: 'Title',
+ msg: 'message',
+ theme: 'bootstrap'
+ }
+ // We listen our service to recieve new toasts from it
+ service.getToasts().subscribe((toast:ToastData) => {
+ expect(toast).not.toBeNull();
+ expect(toast.id).not.toBeNull();
+ expect(toast.title).toBe(options.title);
+ expect(toast.msg).toBe(options.msg);
+ expect(toast.showClose).toBe(true);
+ expect(toast.type).toBe('toasty-type-default');
+ expect(toast.theme).toBe('toasty-theme-bootstrap');
+ expect(toast.onAdd).toBeNull();
+ expect(toast.onRemove).toBeNull();
+ });
+ service.default(options);
+ })
+ );
});
-}
\ No newline at end of file
+});
diff --git a/tsconfig.json b/tsconfig.json
index 57e9c0b..9704972 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -8,10 +8,5 @@
"declaration": true,
"moduleResolution": "node",
"sourceMap": true
- },
- "exclude": [
- "node_modules",
- "typings/index.d.ts",
- "typings/index"
- ]
+ }
}
\ No newline at end of file
diff --git a/typings.json b/typings.json
index 32d1554..7da31ca 100644
--- a/typings.json
+++ b/typings.json
@@ -1,9 +1,7 @@
{
- "globalDevDependencies": {
- "jasmine": "github:DefinitelyTyped/DefinitelyTyped/jasmine/jasmine.d.ts#dd638012d63e069f2c99d06ef4dcc9616a943ee4"
- },
"globalDependencies": {
- "es6-shim": "github:DefinitelyTyped/DefinitelyTyped/es6-shim/es6-shim.d.ts#6697d6f7dadbf5773cb40ecda35a76027e0783b2",
- "node": "github:DefinitelyTyped/DefinitelyTyped/node/node.d.ts#aee0039a2d6686ec78352125010ebb38a7a7d743"
+ "core-js": "registry:dt/core-js#0.0.0+20160725163759",
+ "jasmine": "registry:dt/jasmine#2.2.0+20160621224255",
+ "node": "registry:dt/node#6.0.0+20160909174046"
}
}