feat: add notification functionality
This commit is contained in:
@@ -1 +1,4 @@
|
|||||||
|
@if(this.showNotification()) {
|
||||||
|
<app-notification></app-notification>
|
||||||
|
}
|
||||||
<router-outlet></router-outlet>
|
<router-outlet></router-outlet>
|
||||||
@@ -2,19 +2,29 @@ import { TestBed } from '@angular/core/testing';
|
|||||||
import { App } from './app';
|
import { App } from './app';
|
||||||
import { strings } from './strings';
|
import { strings } from './strings';
|
||||||
import { STRINGS_INJECTOR } from './app.config';
|
import { STRINGS_INJECTOR } from './app.config';
|
||||||
|
import { Notifier } from './services/notifier';
|
||||||
|
import { signal } from '@angular/core';
|
||||||
|
|
||||||
describe('App', () => {
|
describe('App', () => {
|
||||||
|
let notifier: jasmine.SpyObj<Notifier>;
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
|
notifier = jasmine.createSpyObj(Notifier.name, [], {
|
||||||
|
notification$: signal<Notification | null>(null),
|
||||||
|
});
|
||||||
await TestBed.configureTestingModule({
|
await TestBed.configureTestingModule({
|
||||||
imports: [App],
|
imports: [App],
|
||||||
providers: [{ provide: STRINGS_INJECTOR, useValue: strings }],
|
providers: [
|
||||||
|
{ provide: STRINGS_INJECTOR, useValue: strings },
|
||||||
|
{ provide: Notifier, useValue: notifier },
|
||||||
|
],
|
||||||
}).compileComponents();
|
}).compileComponents();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should create the app', () => {
|
it('should create the app', () => {
|
||||||
const fixture = TestBed.createComponent(App);
|
const fixture = TestBed.createComponent(App);
|
||||||
const app = fixture.componentInstance;
|
const app = fixture.componentInstance;
|
||||||
|
TestBed.tick();
|
||||||
expect(app).toBeTruthy();
|
expect(app).toBeTruthy();
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,11 +1,15 @@
|
|||||||
import { Component } from '@angular/core';
|
import { Component, inject } from '@angular/core';
|
||||||
import { RouterOutlet } from '@angular/router';
|
import { RouterOutlet } from '@angular/router';
|
||||||
|
import { Notification } from './components/notification/notification';
|
||||||
|
import { Notifier } from './services/notifier';
|
||||||
|
import { computed } from '@angular/core';
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-root',
|
selector: 'app-root',
|
||||||
imports: [RouterOutlet],
|
imports: [RouterOutlet, Notification],
|
||||||
templateUrl: './app.html',
|
templateUrl: './app.html',
|
||||||
styleUrl: './app.scss',
|
styleUrl: './app.scss',
|
||||||
})
|
})
|
||||||
export class App {
|
export class App {
|
||||||
|
private readonly notifier = inject(Notifier);
|
||||||
|
showNotification = computed(() => this.notifier.notification$() !== null);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user