Differenzansicht 17-standalone
im Vergleich zu 16-guards

← Zurück zur Übersicht | Demo | Quelltext auf GitHub
src/app/admin/book-create/book-create.component.spec.ts ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { ComponentFixture, TestBed } from '@angular/core/testing';
2
+
3
+ import { BookCreateComponent } from './book-create.component';
4
+
5
+ describe('BookCreateComponent', () => {
6
+ let component: BookCreateComponent;
7
+ let fixture: ComponentFixture<BookCreateComponent>;
8
+
9
+ beforeEach(async () => {
10
+ await TestBed.configureTestingModule({
11
+ declarations: [ BookCreateComponent ]
12
+ })
13
+ .compileComponents();
14
+
15
+ fixture = TestBed.createComponent(BookCreateComponent);
16
+ component = fixture.componentInstance;
17
+ fixture.detectChanges();
18
+ });
19
+
20
+ it('should create', () => {
21
+ expect(component).toBeTruthy();
22
+ });
23
+ });
src/app/admin/book-edit/book-edit.component.spec.ts ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { ComponentFixture, TestBed } from '@angular/core/testing';
2
+
3
+ import { BookEditComponent } from './book-edit.component';
4
+
5
+ describe('BookEditComponent', () => {
6
+ let component: BookEditComponent;
7
+ let fixture: ComponentFixture<BookEditComponent>;
8
+
9
+ beforeEach(async () => {
10
+ await TestBed.configureTestingModule({
11
+ declarations: [ BookEditComponent ]
12
+ })
13
+ .compileComponents();
14
+
15
+ fixture = TestBed.createComponent(BookEditComponent);
16
+ component = fixture.componentInstance;
17
+ fixture.detectChanges();
18
+ });
19
+
20
+ it('should create', () => {
21
+ expect(component).toBeTruthy();
22
+ });
23
+ });
src/app/admin/book-form/book-form.component.spec.ts ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { ComponentFixture, TestBed } from '@angular/core/testing';
2
+
3
+ import { BookFormComponent } from './book-form.component';
4
+
5
+ describe('BookFormComponent', () => {
6
+ let component: BookFormComponent;
7
+ let fixture: ComponentFixture<BookFormComponent>;
8
+
9
+ beforeEach(async () => {
10
+ await TestBed.configureTestingModule({
11
+ declarations: [ BookFormComponent ]
12
+ })
13
+ .compileComponents();
14
+
15
+ fixture = TestBed.createComponent(BookFormComponent);
16
+ component = fixture.componentInstance;
17
+ fixture.detectChanges();
18
+ });
19
+
20
+ it('should create', () => {
21
+ expect(component).toBeTruthy();
22
+ });
23
+ });
src/app/admin/form-errors/form-errors.component.spec.ts ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { ComponentFixture, TestBed } from '@angular/core/testing';
2
+
3
+ import { FormErrorsComponent } from './form-errors.component';
4
+
5
+ describe('FormErrorsComponent', () => {
6
+ let component: FormErrorsComponent;
7
+ let fixture: ComponentFixture<FormErrorsComponent>;
8
+
9
+ beforeEach(async () => {
10
+ await TestBed.configureTestingModule({
11
+ declarations: [ FormErrorsComponent ]
12
+ })
13
+ .compileComponents();
14
+
15
+ fixture = TestBed.createComponent(FormErrorsComponent);
16
+ component = fixture.componentInstance;
17
+ fixture.detectChanges();
18
+ });
19
+
20
+ it('should create', () => {
21
+ expect(component).toBeTruthy();
22
+ });
23
+ });
src/app/admin/shared/async-validators.service.spec.ts ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { TestBed } from '@angular/core/testing';
2
+
3
+ import { AsyncValidatorsService } from './async-validators.service';
4
+
5
+ describe('AsyncValidatorsService', () => {
6
+ let service: AsyncValidatorsService;
7
+
8
+ beforeEach(() => {
9
+ TestBed.configureTestingModule({});
10
+ service = TestBed.inject(AsyncValidatorsService);
11
+ });
12
+
13
+ it('should be created', () => {
14
+ expect(service).toBeTruthy();
15
+ });
16
+ });
src/app/app-routing.module.ts CHANGED
@@ -16,7 +16,7 @@ const routes: Routes = [
16
  },
17
  {
18
  path: 'books',
19
- loadChildren: () => import('./books/books.module').then(m => m.BooksModule)
20
  },
21
  {
22
  path: 'admin',
16
  },
17
  {
18
  path: 'books',
19
+ loadChildren: () => import('./books/books.routes').then(m => m.BOOKS_ROUTES)
20
  },
21
  {
22
  path: 'admin',
src/app/books/book-details/book-details.component.spec.ts ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { ComponentFixture, TestBed } from '@angular/core/testing';
2
+
3
+ import { BookDetailsComponent } from './book-details.component';
4
+
5
+ describe('BookDetailsComponent', () => {
6
+ let component: BookDetailsComponent;
7
+ let fixture: ComponentFixture<BookDetailsComponent>;
8
+
9
+ beforeEach(async () => {
10
+ await TestBed.configureTestingModule({
11
+ declarations: [ BookDetailsComponent ]
12
+ })
13
+ .compileComponents();
14
+
15
+ fixture = TestBed.createComponent(BookDetailsComponent);
16
+ component = fixture.componentInstance;
17
+ fixture.detectChanges();
18
+ });
19
+
20
+ it('should create', () => {
21
+ expect(component).toBeTruthy();
22
+ });
23
+ });
src/app/books/book-details/book-details.component.ts CHANGED
@@ -1,14 +1,23 @@
1
  import { Component } from '@angular/core';
2
- import { ActivatedRoute, Router } from '@angular/router';
 
3
  import { Observable } from 'rxjs';
4
 
5
  import { BookStoreService } from '../../shared/book-store.service';
6
  import { Book } from '../../shared/book';
 
 
 
7
 
8
  @Component({
9
  selector: 'bm-book-details',
10
  templateUrl: './book-details.component.html',
11
- styleUrls: ['./book-details.component.css']
 
 
 
 
 
12
  })
13
  export class BookDetailsComponent {
14
  book$: Observable<Book>;
1
  import { Component } from '@angular/core';
2
+ import { AsyncPipe, DatePipe, NgFor, NgIf } from '@angular/common';
3
+ import { ActivatedRoute, Router, RouterLink } from '@angular/router';
4
  import { Observable } from 'rxjs';
5
 
6
  import { BookStoreService } from '../../shared/book-store.service';
7
  import { Book } from '../../shared/book';
8
+ import { IsbnPipe } from '../../shared/isbn.pipe';
9
+ import { LoggedinOnlyDirective } from '../../shared/loggedin-only.directive';
10
+ import { ConfirmDirective } from '../../shared/confirm.directive';
11
 
12
  @Component({
13
  selector: 'bm-book-details',
14
  templateUrl: './book-details.component.html',
15
+ styleUrls: ['./book-details.component.css'],
16
+ standalone: true,
17
+ imports: [
18
+ NgIf, NgFor, DatePipe, AsyncPipe, RouterLink,
19
+ IsbnPipe, LoggedinOnlyDirective, ConfirmDirective
20
+ ]
21
  })
22
  export class BookDetailsComponent {
23
  book$: Observable<Book>;
src/app/books/book-list/book-list.component.spec.ts ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { ComponentFixture, TestBed } from '@angular/core/testing';
2
+
3
+ import { BookListComponent } from './book-list.component';
4
+
5
+ describe('BookListComponent', () => {
6
+ let component: BookListComponent;
7
+ let fixture: ComponentFixture<BookListComponent>;
8
+
9
+ beforeEach(async () => {
10
+ await TestBed.configureTestingModule({
11
+ declarations: [ BookListComponent ]
12
+ })
13
+ .compileComponents();
14
+
15
+ fixture = TestBed.createComponent(BookListComponent);
16
+ component = fixture.componentInstance;
17
+ fixture.detectChanges();
18
+ });
19
+
20
+ it('should create', () => {
21
+ expect(component).toBeTruthy();
22
+ });
23
+ });
src/app/books/book-list/book-list.component.ts CHANGED
@@ -1,13 +1,20 @@
 
1
  import { Component } from '@angular/core';
2
  import { Observable } from 'rxjs';
3
 
4
  import { Book } from '../../shared/book';
5
  import { BookStoreService } from '../../shared/book-store.service';
 
6
 
7
  @Component({
8
  selector: 'bm-book-list',
9
  templateUrl: './book-list.component.html',
10
- styleUrls: ['./book-list.component.css']
 
 
 
 
 
11
  })
12
  export class BookListComponent {
13
  books$: Observable<Book[]>;
1
+ import { AsyncPipe, NgFor, NgIf } from '@angular/common';
2
  import { Component } from '@angular/core';
3
  import { Observable } from 'rxjs';
4
 
5
  import { Book } from '../../shared/book';
6
  import { BookStoreService } from '../../shared/book-store.service';
7
+ import { BookListItemComponent } from '../book-list-item/book-list-item.component';
8
 
9
  @Component({
10
  selector: 'bm-book-list',
11
  templateUrl: './book-list.component.html',
12
+ styleUrls: ['./book-list.component.css'],
13
+ standalone: true,
14
+ imports: [
15
+ NgIf, NgFor, AsyncPipe,
16
+ BookListItemComponent
17
+ ]
18
  })
19
  export class BookListComponent {
20
  books$: Observable<Book[]>;
src/app/books/book-list-item/book-list-item.component.ts CHANGED
@@ -1,10 +1,16 @@
 
1
  import { Component, Input } from '@angular/core';
 
 
 
2
  import { Book } from '../../shared/book';
3
 
4
  @Component({
5
  selector: 'bm-book-list-item',
6
  templateUrl: './book-list-item.component.html',
7
- styleUrls: ['./book-list-item.component.css']
 
 
8
  })
9
  export class BookListItemComponent {
10
  @Input() book?: Book;
1
+ import { NgFor, NgIf } from '@angular/common';
2
  import { Component, Input } from '@angular/core';
3
+ import { RouterLink } from '@angular/router';
4
+
5
+ import { IsbnPipe } from '../../shared/isbn.pipe';
6
  import { Book } from '../../shared/book';
7
 
8
  @Component({
9
  selector: 'bm-book-list-item',
10
  templateUrl: './book-list-item.component.html',
11
+ styleUrls: ['./book-list-item.component.css'],
12
+ standalone: true,
13
+ imports: [NgIf, NgFor, RouterLink, IsbnPipe]
14
  })
15
  export class BookListItemComponent {
16
  @Input() book?: Book;
src/app/books/books.module.ts DELETED
@@ -1,26 +0,0 @@
1
- import { NgModule } from '@angular/core';
2
- import { CommonModule } from '@angular/common';
3
-
4
- import { BooksRoutingModule } from './books-routing.module';
5
- import { BookListComponent } from './book-list/book-list.component';
6
- import { BookListItemComponent } from './book-list-item/book-list-item.component';
7
- import { BookDetailsComponent } from './book-details/book-details.component';
8
- import { IsbnPipe } from './shared/isbn.pipe';
9
- import { ConfirmDirective } from './shared/confirm.directive';
10
- import { LoggedinOnlyDirective } from './shared/loggedin-only.directive';
11
-
12
- @NgModule({
13
- declarations: [
14
- BookListComponent,
15
- BookListItemComponent,
16
- BookDetailsComponent,
17
- IsbnPipe,
18
- ConfirmDirective,
19
- LoggedinOnlyDirective
20
- ],
21
- imports: [
22
- CommonModule,
23
- BooksRoutingModule
24
- ]
25
- })
26
- export class BooksModule { }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
src/app/books/{books-routing.module.ts → books.routes.ts} RENAMED
@@ -1,10 +1,8 @@
1
- import { NgModule } from '@angular/core';
2
- import { RouterModule, Routes } from '@angular/router';
3
-
4
  import { BookDetailsComponent } from './book-details/book-details.component';
5
  import { BookListComponent } from './book-list/book-list.component';
6
 
7
- const routes: Routes = [
8
  {
9
  path: '',
10
  component: BookListComponent,
@@ -14,9 +12,3 @@ const routes: Routes = [
14
  component: BookDetailsComponent,
15
  }
16
  ];
17
-
18
- @NgModule({
19
- imports: [RouterModule.forChild(routes)],
20
- exports: [RouterModule]
21
- })
22
- export class BooksRoutingModule { }
1
+ import { Routes } from '@angular/router';
 
 
2
  import { BookDetailsComponent } from './book-details/book-details.component';
3
  import { BookListComponent } from './book-list/book-list.component';
4
 
5
+ export const BOOKS_ROUTES: Routes = [
6
  {
7
  path: '',
8
  component: BookListComponent,
12
  component: BookDetailsComponent,
13
  }
14
  ];
 
 
 
 
 
 
src/app/home/home.component.spec.ts CHANGED
@@ -1,4 +1,3 @@
1
- import { NO_ERRORS_SCHEMA } from '@angular/core';
2
  import { ComponentFixture, TestBed } from '@angular/core/testing';
3
 
4
  import { HomeComponent } from './home.component';
@@ -9,8 +8,7 @@ describe('HomeComponent', () => {
9
 
10
  beforeEach(async () => {
11
  await TestBed.configureTestingModule({
12
- declarations: [ HomeComponent ],
13
- schemas: [NO_ERRORS_SCHEMA]
14
  })
15
  .compileComponents();
16
 
 
1
  import { ComponentFixture, TestBed } from '@angular/core/testing';
2
 
3
  import { HomeComponent } from './home.component';
8
 
9
  beforeEach(async () => {
10
  await TestBed.configureTestingModule({
11
+ declarations: [ HomeComponent ]
 
12
  })
13
  .compileComponents();
14
 
src/app/search/search.component.spec.ts ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { ComponentFixture, TestBed } from '@angular/core/testing';
2
+
3
+ import { SearchComponent } from './search.component';
4
+
5
+ describe('SearchComponent', () => {
6
+ let component: SearchComponent;
7
+ let fixture: ComponentFixture<SearchComponent>;
8
+
9
+ beforeEach(async () => {
10
+ await TestBed.configureTestingModule({
11
+ declarations: [ SearchComponent ]
12
+ })
13
+ .compileComponents();
14
+
15
+ fixture = TestBed.createComponent(SearchComponent);
16
+ component = fixture.componentInstance;
17
+ fixture.detectChanges();
18
+ });
19
+
20
+ it('should create', () => {
21
+ expect(component).toBeTruthy();
22
+ });
23
+ });
src/app/shared/book-store.service.spec.ts ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { TestBed } from '@angular/core/testing';
2
+
3
+ import { BookStoreService } from './book-store.service';
4
+
5
+ describe('BookStoreService', () => {
6
+ let service: BookStoreService;
7
+
8
+ beforeEach(() => {
9
+ TestBed.configureTestingModule({});
10
+ service = TestBed.inject(BookStoreService);
11
+ });
12
+
13
+ it('should be created', () => {
14
+ expect(service).toBeTruthy();
15
+ });
16
+ });
src/app/{books/shared → shared}/confirm.directive.ts RENAMED
@@ -1,7 +1,8 @@
1
  import { Directive, EventEmitter, HostListener, Input, Output } from '@angular/core';
2
 
3
  @Directive({
4
- selector: '[bmConfirm]'
 
5
  })
6
  export class ConfirmDirective {
7
  @Input('bmConfirm') confirmText?: string;
1
  import { Directive, EventEmitter, HostListener, Input, Output } from '@angular/core';
2
 
3
  @Directive({
4
+ selector: '[bmConfirm]',
5
+ standalone: true
6
  })
7
  export class ConfirmDirective {
8
  @Input('bmConfirm') confirmText?: string;
src/app/{books/shared → shared}/isbn.pipe.ts RENAMED
@@ -1,7 +1,8 @@
1
  import { Pipe, PipeTransform } from '@angular/core';
2
 
3
  @Pipe({
4
- name: 'isbn'
 
5
  })
6
  export class IsbnPipe implements PipeTransform {
7
 
1
  import { Pipe, PipeTransform } from '@angular/core';
2
 
3
  @Pipe({
4
+ name: 'isbn',
5
+ standalone: true
6
  })
7
  export class IsbnPipe implements PipeTransform {
8
 
src/app/shared/loggedin-only.directive.spec.ts ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ import { LoggedinOnlyDirective } from './loggedin-only.directive';
2
+
3
+ describe('LoggedinOnlyDirective', () => {
4
+ it('should create an instance', () => {
5
+ const directive = new LoggedinOnlyDirective();
6
+ expect(directive).toBeTruthy();
7
+ });
8
+ });
src/app/{books/shared → shared}/loggedin-only.directive.ts RENAMED
@@ -1,10 +1,11 @@
1
  import { Directive, OnDestroy, TemplateRef, ViewContainerRef } from '@angular/core';
2
  import { Subject, takeUntil } from 'rxjs';
3
 
4
- import { AuthService } from '../../shared/auth.service';
5
 
6
  @Directive({
7
- selector: '[bmLoggedinOnly]'
 
8
  })
9
  export class LoggedinOnlyDirective implements OnDestroy {
10
  private destroy$ = new Subject<void>();
1
  import { Directive, OnDestroy, TemplateRef, ViewContainerRef } from '@angular/core';
2
  import { Subject, takeUntil } from 'rxjs';
3
 
4
+ import { AuthService } from './auth.service';
5
 
6
  @Directive({
7
+ selector: '[bmLoggedinOnly]',
8
+ standalone: true
9
  })
10
  export class LoggedinOnlyDirective implements OnDestroy {
11
  private destroy$ = new Subject<void>();