Skip to content

Instantly share code, notes, and snippets.

View mahulst's full-sized avatar

Michel van der Hulst mahulst

  • Amsterdam
  • 05:55 (UTC +02:00)
View GitHub Profile
import { Injectable } from '@angular/core';
import { Observable, ReplaySubject } from 'rxjs/Rx';
// Dummy class to show mocking without angular2 dependency injection
export class AnalyticsService {
trackDevices(device) {
console.log(device);
return device;
}
}
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { TodoListComponent } from './todolist';
import { Http } from '@angular/http';
import { Observable } from 'rxjs';
import { By } from '@angular/platform-browser';
describe('TodoListComponent', () => {
// Reference to components we can use in our tests
let stub: any = {},
componentFixture: ComponentFixture<TodoListComponent>,
import { Component, OnInit } from '@angular/core';
import { Http } from '@angular/http';
import { Observable } from 'rxjs';
export interface Todo {
name: string;
completed: boolean;
}
@Component({
import { TestBed, ComponentFixture } from '@angular/core/testing';
import { Component } from '@angular/core';
import { AnalyticsService } from '../services/analytics.service';
import {
AnalyticsEventDirective
} from './analytics-events.directive';
// create a component using the directive we want to test
// eventString is a variable we can change to test behaviour
import { Directive, HostListener, Input } from '@angular/core';
import { AnalyticsService } from './analytics.service';
/**
* @description
* This directive adds a click listener on an element
* and send events to google analytics.
*
* Usage:
* Add myGA as an attribute to the clickable element.
* Provide a string with an category, label and action