72 lines
8.3 KiB
JavaScript
72 lines
8.3 KiB
JavaScript
|
import { describe, fdescribe, xdescribe, it, fit, xit, beforeEach, afterEach, beforeEachProviders, inject } from 'angular2/testing';
|
||
|
import { provide } from 'angular2/core';
|
||
|
var db;
|
||
|
class MyService {
|
||
|
}
|
||
|
class MyMockService {
|
||
|
}
|
||
|
// #docregion describeIt
|
||
|
describe('some component', () => {
|
||
|
it('does something', () => {
|
||
|
// This is a test.
|
||
|
});
|
||
|
});
|
||
|
// #enddocregion
|
||
|
// #docregion fdescribe
|
||
|
fdescribe('some component', () => {
|
||
|
it('has a test', () => {
|
||
|
// This test will run.
|
||
|
});
|
||
|
});
|
||
|
describe('another component', () => { it('also has a test', () => { throw 'This test will not run.'; }); });
|
||
|
// #enddocregion
|
||
|
// #docregion xdescribe
|
||
|
xdescribe('some component', () => { it('has a test', () => { throw 'This test will not run.'; }); });
|
||
|
describe('another component', () => {
|
||
|
it('also has a test', () => {
|
||
|
// This test will run.
|
||
|
});
|
||
|
});
|
||
|
// #enddocregion
|
||
|
// #docregion fit
|
||
|
describe('some component', () => {
|
||
|
fit('has a test', () => {
|
||
|
// This test will run.
|
||
|
});
|
||
|
it('has another test', () => { throw 'This test will not run.'; });
|
||
|
});
|
||
|
// #enddocregion
|
||
|
// #docregion xit
|
||
|
describe('some component', () => {
|
||
|
xit('has a test', () => { throw 'This test will not run.'; });
|
||
|
it('has another test', () => {
|
||
|
// This test will run.
|
||
|
});
|
||
|
});
|
||
|
// #enddocregion
|
||
|
// #docregion beforeEach
|
||
|
describe('some component', () => {
|
||
|
beforeEach(() => { db.connect(); });
|
||
|
it('uses the db', () => {
|
||
|
// Database is connected.
|
||
|
});
|
||
|
});
|
||
|
// #enddocregion
|
||
|
// #docregion beforeEachProviders
|
||
|
describe('some component', () => {
|
||
|
beforeEachProviders(() => [provide(MyService, { useClass: MyMockService })]);
|
||
|
it('uses MyService', inject([MyService], (service) => {
|
||
|
// service is an instance of MyMockService.
|
||
|
}));
|
||
|
});
|
||
|
// #enddocregion
|
||
|
// #docregion afterEach
|
||
|
describe('some component', () => {
|
||
|
afterEach((done) => { db.reset().then((_) => done()); });
|
||
|
it('uses the db', () => {
|
||
|
// This test can leave the database in a dirty state.
|
||
|
// The afterEach will ensure it gets reset.
|
||
|
});
|
||
|
});
|
||
|
// #enddocregion
|
||
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGVzdGluZy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbImFuZ3VsYXIyL2V4YW1wbGVzL3Rlc3RpbmcvdHMvdGVzdGluZy50cyJdLCJuYW1lcyI6WyJNeVNlcnZpY2UiLCJNeU1vY2tTZXJ2aWNlIl0sIm1hcHBpbmdzIjoiT0FBTyxFQUNMLFFBQVEsRUFDUixTQUFTLEVBQ1QsU0FBUyxFQUNULEVBQUUsRUFDRixHQUFHLEVBQ0gsR0FBRyxFQUNILFVBQVUsRUFDVixTQUFTLEVBQ1QsbUJBQW1CLEVBQ25CLE1BQU0sRUFDUCxNQUFNLGtCQUFrQjtPQUNsQixFQUFDLE9BQU8sRUFBQyxNQUFNLGVBQWU7QUFFckMsSUFBSSxFQUFPLENBQUM7QUFDWjtBQUFpQkEsQ0FBQ0E7QUFDbEI7QUFBMENDLENBQUNBO0FBRTNDLHdCQUF3QjtBQUN4QixRQUFRLENBQUMsZ0JBQWdCLEVBQUU7SUFDekIsRUFBRSxDQUFDLGdCQUFnQixFQUFFO1FBQ0ksa0JBQWtCO0lBQ3RCLENBQUMsQ0FBQyxDQUFDO0FBQzFCLENBQUMsQ0FBQyxDQUFDO0FBQ0gsZ0JBQWdCO0FBRWhCLHVCQUF1QjtBQUN2QixTQUFTLENBQUMsZ0JBQWdCLEVBQUU7SUFDMUIsRUFBRSxDQUFDLFlBQVksRUFBRTtRQUNJLHNCQUFzQjtJQUMxQixDQUFDLENBQUMsQ0FBQztBQUN0QixDQUFDLENBQUMsQ0FBQztBQUNILFF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