|
| 1 | +import { |
| 2 | + describe, |
| 3 | + fdescribe, |
| 4 | + xdescribe, |
| 5 | + it, |
| 6 | + fit, |
| 7 | + xit, |
| 8 | + beforeEach, |
| 9 | + afterEach, |
| 10 | + beforeEachProviders, |
| 11 | + inject |
| 12 | +} from 'angular2/testing'; |
| 13 | +import {provide} from 'angular2/core'; |
| 14 | + |
| 15 | +var db: any; |
| 16 | +class MyService {} |
| 17 | +class MyMockService implements MyService {} |
| 18 | + |
| 19 | +// #docregion describeIt |
| 20 | +describe('some component', () => { |
| 21 | + it('does something', () => { |
| 22 | + // This is a test. |
| 23 | + }); |
| 24 | +}); |
| 25 | +// #enddocregion |
| 26 | + |
| 27 | +// #docregion fdescribe |
| 28 | +fdescribe('some component', () => { |
| 29 | + it('has a test', () => { |
| 30 | + // This test will run. |
| 31 | + }); |
| 32 | +}); |
| 33 | +describe('another component', |
| 34 | + () => { it('also has a test', () => { throw 'This test will not run.'; }); }); |
| 35 | +// #enddocregion |
| 36 | + |
| 37 | +// #docregion xdescribe |
| 38 | +xdescribe('some component', () => { it('has a test', () => {throw 'This test will not run.'}); }); |
| 39 | +describe('another component', () => { |
| 40 | + it('also has a test', () => { |
| 41 | + // This test will run. |
| 42 | + }); |
| 43 | +}); |
| 44 | +// #enddocregion |
| 45 | + |
| 46 | +// #docregion fit |
| 47 | +describe('some component', () => { |
| 48 | + fit('has a test', () => { |
| 49 | + // This test will run. |
| 50 | + }); |
| 51 | + it('has another test', () => { throw 'This test will not run.'; }); |
| 52 | +}); |
| 53 | +// #enddocregion |
| 54 | + |
| 55 | +// #docregion xit |
| 56 | +describe('some component', () => { |
| 57 | + xit('has a test', () => { throw 'This test will not run.'; }); |
| 58 | + it('has another test', () => { |
| 59 | + // This test will run. |
| 60 | + }); |
| 61 | +}); |
| 62 | +// #enddocregion |
| 63 | + |
| 64 | +// #docregion beforeEach |
| 65 | +describe('some component', () => { |
| 66 | + beforeEach(() => { db.connect(); }); |
| 67 | + it('uses the db', () => { |
| 68 | + // Database is connected. |
| 69 | + }); |
| 70 | +}); |
| 71 | +// #enddocregion |
| 72 | + |
| 73 | +// #docregion beforeEachProviders |
| 74 | +describe('some component', () => { |
| 75 | + beforeEachProviders(() => [provide(MyService, {useClass: MyMockService})]); |
| 76 | + it('uses MyService', inject([MyService], (service) => { |
| 77 | + // service is an instance of MyMockService. |
| 78 | + })); |
| 79 | +}); |
| 80 | +// #enddocregion |
| 81 | + |
| 82 | +// #docregion afterEach |
| 83 | +describe('some component', () => { |
| 84 | + afterEach((done) => { db.reset().then((_) => done()); }); |
| 85 | + it('uses the db', () => { |
| 86 | + // This test can leave the database in a dirty state. |
| 87 | + // The afterEach will ensure it gets reset. |
| 88 | + }); |
| 89 | +}); |
| 90 | +// #enddocregion |
0 commit comments