Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Arrow up icon
GO TO TOP
Mastering Angular Components

You're reading from   Mastering Angular Components Build component-based user interfaces with Angular

Arrow left icon
Product type Paperback
Published in Jul 2018
Publisher Packt
ISBN-13 9781788293532
Length 402 pages
Edition 2nd Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
 Kunz Kunz
Author Profile Icon Kunz
Kunz
Arrow right icon
View More author details
Toc

Table of Contents (18) Chapters Close

Title Page
Copyright and Credits
Dedication
Packt Upsell
Contributors
Preface
1. Component-Based User Interfaces FREE CHAPTER 2. Ready, Set, Go! 3. Dealing with Data and State 4. Thinking in Projects 5. Component-Based Routing 6. Keeping up with Activities 7. Components for User Experience 8. Time Will Tell 9. Spaceship Dashboard 10. Putting Things to the Test 1. Other Books You May Enjoy Index

Writing our first test


Now that we are all set with the testing setup, we can start writing our first test. In this section, we will create a first test for the efforts component that we created in Chapter 8, Time Will Tell.

As Angular components are just classes, we can already test a lot of their functionality by instantiating the component class and testing its methods. Tests that can be performed like this should always be considered first. Tests that don't involve the rendering logic of your components can run without Angular compiling and bootstrap the component.

The efforts component uses a method to add a certain amount of hours to the effective time worked on a task. Within the template of the efforts component, we're providing three buttons, to add some common amounts of hours. Let's create our first test for the method, addEffectiveHours, in our efforts component. For this test, we'd like to start simple and create the component class instance manually. This allows us to test its...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime
Visually different images