Testing directives
Directives are usually quite straightforward in their overall shape, being pretty much components with no view attached. The fact that directives usually work with components gives us a very good idea of how to proceed when testing them.
A directive can be simple in the sense that it has no external dependencies. Consider the following directive that we created in Chapter 4, Enhance Components with Pipes and Directives:
copyright.directive.ts
import { Directive, ElementRef, Renderer2 } from '@angular/core';
@Directive({
selector: '[appCopyright]'
})
export class CopyrightDirective {
constructor(el: ElementRef, renderer: Renderer2) {
renderer.addClass(el.nativeElement, 'copyright');
renderer.setProperty(
el.nativeElement,
...