docs(*): Document a lot more symbols that are missing comments in our generated docs.
This commit is contained in:
@ -0,0 +1,30 @@
|
||||
import {Component} from 'angular2/core';
|
||||
import {MinLengthValidator, MaxLengthValidator} from 'angular2/common';
|
||||
|
||||
// #docregion min
|
||||
@Component({
|
||||
selector: 'min-cmp',
|
||||
directives: [MinLengthValidator],
|
||||
template: `
|
||||
<form>
|
||||
<p>Year: <input ngControl="year" minlength="2"></p>
|
||||
</form>
|
||||
`
|
||||
})
|
||||
class MinLengthTestComponent {
|
||||
}
|
||||
// #enddocregion
|
||||
|
||||
// #docregion max
|
||||
@Component({
|
||||
selector: 'max-cmp',
|
||||
directives: [MaxLengthValidator],
|
||||
template: `
|
||||
<form>
|
||||
<p>Year: <input ngControl="year" maxlength="4"></p>
|
||||
</form>
|
||||
`
|
||||
})
|
||||
class MaxLengthTestComponent {
|
||||
}
|
||||
// #enddocregion
|
@ -0,0 +1,19 @@
|
||||
import {provide} from 'angular2/core';
|
||||
import {bootstrap} from 'angular2/bootstrap';
|
||||
import {UrlResolver} from 'angular2/compiler';
|
||||
|
||||
var MyApp;
|
||||
|
||||
// #docregion url_resolver
|
||||
class MyUrlResolver extends UrlResolver {
|
||||
resolve(baseUrl: string, url: string): string {
|
||||
// Serve CSS files from a special CDN.
|
||||
if (url.substr(-4) === '.css') {
|
||||
return super.resolve('http://cdn.myapp.com/css/', url);
|
||||
}
|
||||
return super.resolve(baseUrl, url);
|
||||
}
|
||||
}
|
||||
|
||||
bootstrap(MyApp, [provide(UrlResolver, {useClass: MyUrlResolver})]);
|
||||
// #enddocregion
|
@ -0,0 +1,16 @@
|
||||
import {DebugElement, Scope} from 'angular2/core';
|
||||
|
||||
var debugElement: DebugElement;
|
||||
var predicate;
|
||||
|
||||
// #docregion scope_all
|
||||
debugElement.query(predicate, Scope.all);
|
||||
// #enddocregion
|
||||
|
||||
// #docregion scope_light
|
||||
debugElement.query(predicate, Scope.light);
|
||||
// #enddocregion
|
||||
|
||||
// #docregion scope_view
|
||||
debugElement.query(predicate, Scope.view);
|
||||
// #enddocregion
|
17
modules/angular2/examples/platform/dom/debug/ts/by/by.ts
Normal file
17
modules/angular2/examples/platform/dom/debug/ts/by/by.ts
Normal file
@ -0,0 +1,17 @@
|
||||
import {By} from 'angular2/platform/browser';
|
||||
import {DebugElement, Scope} from 'angular2/core';
|
||||
|
||||
var debugElement: DebugElement;
|
||||
class MyDirective {}
|
||||
|
||||
// #docregion by_all
|
||||
debugElement.query(By.all(), Scope.all);
|
||||
// #enddocregion
|
||||
|
||||
// #docregion by_css
|
||||
debugElement.query(By.css('[attribute]'), Scope.all);
|
||||
// #enddocregion
|
||||
|
||||
// #docregion by_directive
|
||||
debugElement.query(By.directive(MyDirective), Scope.all);
|
||||
// #enddocregion
|
@ -0,0 +1,10 @@
|
||||
import {Component} from 'angular2/core';
|
||||
import {bootstrap, ELEMENT_PROBE_PROVIDERS} from 'angular2/platform/browser';
|
||||
|
||||
@Component({selector: 'my-component'})
|
||||
class MyAppComponent {
|
||||
}
|
||||
|
||||
// #docregion providers
|
||||
bootstrap(MyAppComponent, [ELEMENT_PROBE_PROVIDERS]);
|
||||
// #enddocregion
|
29
modules/angular2/examples/testing/ts/fake_async.ts
Normal file
29
modules/angular2/examples/testing/ts/fake_async.ts
Normal file
@ -0,0 +1,29 @@
|
||||
import {describe, it, fakeAsync, expect, tick, clearPendingTimers} from 'angular2/testing';
|
||||
|
||||
// #docregion basic
|
||||
describe('this test', () => {
|
||||
it('looks async but is synchronous', <any>fakeAsync((): void => {
|
||||
var flag = false;
|
||||
setTimeout(() => { flag = true; }, 100);
|
||||
expect(flag).toBe(false);
|
||||
tick(50);
|
||||
expect(flag).toBe(false);
|
||||
tick(50);
|
||||
expect(flag).toBe(true);
|
||||
}));
|
||||
});
|
||||
// #enddocregion
|
||||
|
||||
// #docregion pending
|
||||
describe('this test', () => {
|
||||
it('aborts a timer', <any>fakeAsync((): void => {
|
||||
// This timer is scheduled but doesn't need to complete for the
|
||||
// test to pass (maybe it's a timeout for some operation).
|
||||
// Leaving it will cause the test to fail...
|
||||
setTimeout(() => {}, 100);
|
||||
|
||||
// Unless we clean it up first.
|
||||
clearPendingTimers();
|
||||
}));
|
||||
});
|
||||
// #enddocregion
|
40
modules/angular2/examples/testing/ts/matchers.ts
Normal file
40
modules/angular2/examples/testing/ts/matchers.ts
Normal file
@ -0,0 +1,40 @@
|
||||
import {expect} from 'angular2/testing';
|
||||
|
||||
var value: any;
|
||||
var element: any;
|
||||
var exception: any;
|
||||
|
||||
abstract class OtherClass {}
|
||||
class SomeClass {}
|
||||
|
||||
// #docregion toBePromise
|
||||
expect(value).toBePromise();
|
||||
// #enddocregion
|
||||
|
||||
// #docregion toBeAnInstanceOf
|
||||
expect(value).toBeAnInstanceOf(SomeClass);
|
||||
// #enddocregion
|
||||
|
||||
// #docregion toHaveText
|
||||
expect(element).toHaveText('Hello world!');
|
||||
// #enddocregion
|
||||
|
||||
// #docregion toHaveCssClass
|
||||
expect(element).toHaveCssClass('current');
|
||||
// #enddocregion
|
||||
|
||||
// #docregion toHaveCssStyle
|
||||
expect(element).toHaveCssStyle({width: '100px', height: 'auto'});
|
||||
// #enddocregion
|
||||
|
||||
// #docregion toContainError
|
||||
expect(exception).toContainError('Failed to load');
|
||||
// #enddocregion
|
||||
|
||||
// #docregion toThrowErrorWith
|
||||
expect(() => { throw 'Failed to load'; }).toThrowErrorWith('Failed to load');
|
||||
// #enddocregion
|
||||
|
||||
// #docregion toImplement
|
||||
expect(SomeClass).toImplement(OtherClass);
|
||||
// #enddocregion
|
Reference in New Issue
Block a user