This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Protractor configuration file, see link for more information | |
| // https://github.com/angular/protractor/blob/master/lib/config.ts | |
| exports.config = { | |
| allScriptsTimeout: 11000, | |
| capabilities: { | |
| 'browserName': 'chrome' | |
| }, | |
| directConnect: true, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Feature: Search | |
| As a developer using Angular | |
| I need to look-up classes and guidelines | |
| So that I can concentrate on building awesome applications | |
| Scenario: Type in a search-term | |
| Given I am on the angular.io site | |
| When I type "foo" into the search input field | |
| Then I should see some results in the search overlay |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Feature: ReactiveConf Lightning Talks are awesome | |
| As a visitor of https://reactiveconf.com/ | |
| I want to learn about Cucumber and Protractor | |
| So that I can test my awesome applications like my users do | |
| Scenario: Curiosity is killing me | |
| Given this proposal for #ReactiveConf 2017 open call for Lightning talks | |
| When you star this summary on GitHub | |
| Then you can go and listen to the talk | |
| But you can also retweet: https://twitter.com/davidh_23/status/889051659711774720 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class LruCache<T> { | |
| private values: Map<string, T> = new Map<string, T>(); | |
| private maxEntries: number = 20; | |
| public get(key: string): T { | |
| const hasKey = this.values.has(key); | |
| let entry: T; | |
| if (hasKey) { | |
| // peek the entry, re-insert for LRU strategy |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { TestBed, async, fakeAsync, tick } from '@angular/core/testing'; | |
| import { NumberComponent } from './number.component'; | |
| describe('NumberComponent', () => { | |
| beforeEach(async(() => { | |
| TestBed.configureTestingModule({ | |
| declarations: [ NumberComponent ], | |
| }).compileComponents(); | |
| })); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { Component, EventEmitter, Input, Output } from '@angular/core'; | |
| /** | |
| * A very dumb replacement for `<input type="number">`. | |
| * | |
| * Usage: `<my-number [value]="99" (onValueChanges)="changed($event)></my-number> | |
| */ | |
| @Component({ | |
| selector: 'my-number', | |
| template: '<input type="text" [value]="value" (change)="onChange($event.target.value)">' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| describe(`FeatureService`, () => { | |
| /** ... set up ... **/ | |
| it(`should emit 'true' for 200 Ok`, | |
| async(inject([ FeatureService, MockBackend ], | |
| (service: FeatureService, mockBackend: MockBackend) => { | |
| // 1. prepare fake response from `MockBackend` | |
| mockBackend.connections.subscribe((c: MockConnection) => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| describe(`FeatureService`, () => { | |
| /** ... set up ... **/ | |
| it(`should emit 'false' for 401 Unauthorized`, | |
| async(inject([ FeatureService, MockBackend ], | |
| (service: FeatureService, mockBackend: MockBackend) => { | |
| // 0. prepare fake response from `MockBackend` | |
| mockBackend.connections.subscribe((c: MockConnection) => { | |
| // 2a. expect `FeatureSerivice` to make a proper request |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { Injector } from '@angular/core'; | |
| import { async, inject, TestBed } from '@angular/core/testing'; | |
| import { Http, HttpModule, Request, RequestMethod, RequestOptions, Response, | |
| ResponseOptions, URLSearchParams, XHRBackend } from '@angular/http'; | |
| import { MockBackend, MockConnection } from '@angular/http/testing'; | |
| describe('FeatureService', () => { | |
| let backend: MockBackend; | |
| //setup |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** This class implements some features that should be tested. */ | |
| @Injectable() | |
| export class FeatureService { | |
| constructor( | |
| private http: Http | |
| ) {} | |
| login(user: string, password: string): Observable<boolean> { | |
| let body = new URLSearchParams(); |