Book Image

Mastering Angular Components - Second Edition

By : Kunz
Book Image

Mastering Angular Components - Second Edition

By: Kunz

Overview of this book

Mastering Angular Components will help you learn how to invent, build, and manage shared and reusable components for your web projects. Angular components are an integral part of any Angular app and are responsible for performing specific tasks in controlling the user interface. Complete with detailed explanations of essential concepts and practical examples, the book begins by helping you build basic layout components, along with developing a fully functional task-management application using Angular. You’ll then learn how to create layout components and build clean data and state architecture for your application. The book will even help you understand component-based routing and create components that render Scalable Vector Graphics (SVG). Toward the concluding chapters, you’ll be able to visualize data using the third-party library Chartist and create a plugin architecture using Angular components. By the end of this book, you will have mastered the component-based architecture in Angular and have the skills you need to build modern and clean user interfaces.
Table of Contents (12 chapters)

Testing component interaction

Although UI interaction testing is probably part of end-to-end testing, we'll look at how to test basic user interaction with your components. In this topic, we'll test the efforts component when the user clicks on one of the buttons to add effective effort hours.

Let's add a new test to our existing efforts component test file, located on the path src/app/efforts/efforts/efforts.component.spec.ts:

  it('should add one day of effective efforts on button click', () => {
// Given
const day = 3600000 * 8;
const component = fixture.componentInstance;
component.efforts = {
estimated: 0,
effective: 0
};
const addDayButton = fixture.debugElement
.queryAll(By.css('button'))[2];
spyOn(component.outEffortsChange, 'emit');

// When
addDayButton.triggerEventHandler(&apos...