Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Learning Angular, Fourth Edition
  • Toc
  • feedback
Learning Angular, Fourth Edition

Learning Angular, Fourth Edition

By : Aristeidis Bampakos, Pablo Deeleman
4.7 (32)
close
Learning Angular, Fourth Edition

Learning Angular, Fourth Edition

4.7 (32)
By: Aristeidis Bampakos, Pablo Deeleman

Overview of this book

As Angular continues to reign as one of the top JavaScript frameworks, more developers are seeking out the best way to get started with this extraordinarily flexible and secure framework. Learning Angular, now in its fourth edition, will show you how you can use it to achieve cross-platform high performance with the latest web techniques, extensive integration with modern web standards, and integrated development environments (IDEs). The book is especially useful for those new to Angular and will help you to get to grips with the bare bones of the framework to start developing Angular apps. You'll learn how to develop apps by harnessing the power of the Angular command-line interface (CLI), write unit tests, style your apps by following the Material Design guidelines, and finally, deploy them to a hosting provider. Updated for Angular 15, this new edition covers lots of new features and tutorials that address the current frontend web development challenges. You’ll find a new dedicated chapter on observables and RxJS, more on error handling and debugging in Angular, and new real-life examples. By the end of this book, you’ll not only be able to create Angular applications with TypeScript from scratch, but also enhance your coding skills with best practices.
Table of Contents (17 chapters)
close
15
Other Books You May Enjoy
16
Index

Testing pipes

As we learned in Chapter 5, Enrich Applications Using Pipes and Directives, a pipe is a TypeScript class that implements the PipeTransform interface. It exposes a transform method, which is usually synchronous, which means it is straightforward to test. The list.pipe.ts file contains a pipe that converts a comma-separated string into a list:

import { Pipe, PipeTransform } from '@angular/core';
@Pipe({
  name: 'list'
})
export class ListPipe implements PipeTransform {
  transform(value: string): string[] {
    return value.split(',');
  }
}

Writing a test for it is simple. The only thing that we need to do is to instantiate an instance of ListPipe and verify the outcome of the transform method with some mock data:

import { ListPipe } from './list.pipe';
describe('ListPipe', () => {
  it('create an instance', () => {
    const pipe = new ListPipe();
    expect(pipe).toBeTruthy...
bookmark search playlist download font-size

Change the font size

margin-width

Change margin width

day-mode

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Delete Bookmark

Modal Close icon
Are you sure you want to delete it?
Cancel
Yes, Delete