當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript mocha.describe函數代碼示例

本文整理匯總了TypeScript中angular2-testing-lite/mocha.describe函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript describe函數的具體用法?TypeScript describe怎麽用?TypeScript describe使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了describe函數的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: describe

describe("Test: app.spec.ts", () => {
  it("can instantiate", async(() => {
    let store = new Store(null);
    assert(!!store);
  }));

  describe("---", () => {
    it("instanceof Store", async(() => {
      const sc = new StoreController(new Store(null));
      const store = sc.getStoreSafely();
      assert(store instanceof Store);
    }));

    it("store.key check", async(() => {
      const sc = new StoreController([new Store(null), new Store('second')]);
      const mainStore = sc.getStoreSafely();
      const secondStore = sc.getStoreSafely('second');
      assert(mainStore.key === '__main__');
      assert(secondStore.key === 'second');
    }));

    it('should fail', async(() => {
      assert('2' === '3');
    }));
  });
});
開發者ID:ovrmrw,項目名稱:shuttle-store-sample,代碼行數:26,代碼來源:app.spec.ts

示例2: describe

describe('Component: WeatherWidget', () => {
  let builder: TestComponentBuilder;

  beforeEachProviders(() => [KelvinToCelsiusPipe]);

  beforeEach(inject([ TestComponentBuilder ], (tcb: TestComponentBuilder) => {
    builder = tcb.overrideProviders(
      WeatherWidget,
      [ provide(OpenWeatherApi, { useClass : MockOpenWeatherApi }) ]);
  }));

  it('can create', () => {
    return builder.createAsync(WeatherWidget).then(fixture => {
      expect(fixture).to.exist;
    });
  });

  it('should display the city name', () => {
    return builder.createAsync(WeatherWidget).then(fixture => {
      let component = fixture.componentInstance,
          element = fixture.nativeElement;

      component.city = 'Berlin';

      fixture.detectChanges();
      expect(element.querySelector('.weather__city').innerText)
        .to.equal('Berlin');
    });
  });

  it('should transform the temperature from Kelvin to Celcius and display it',
     () => {
       return builder.createAsync(WeatherWidget).then(fixture => {
         let component = fixture.componentInstance,
             element = fixture.nativeElement;

         component.city = 'Berlin';

         fixture.detectChanges();
         expect(element.querySelector('.weather__detail__temp').innerText)
           .to.equal('21.91°C');
       });
     });

  it('should contain an icon with a url by open weather api', () => {
    return builder.createAsync(WeatherWidget).then(fixture => {
      let component = fixture.componentInstance,
          element = fixture.nativeElement;

      component.city = 'Berlin';

      fixture.detectChanges();
      expect(element.querySelector('img').getAttribute('src'))
        .to.equal('http://openweathermap.org/img/w/01d.png');
      expect(component.generateIconUrl())
        .to.equal('http://openweathermap.org/img/w/01d.png');
    });
  });
});
開發者ID:luhmann,項目名稱:ng2-webpack-weather-widget,代碼行數:59,代碼來源:weather-widget.component.spec.ts

示例3: describe

describe('WeatherWidget: Open Weather API Service', () => {
  beforeEachProviders(() => [BaseRequestOptions, MockBackend, provide(Http, {
                               useFactory : (backend: MockBackend,
                                             options: BaseRequestOptions) => {
                                 return new Http(backend, options);
                               },
                               deps : [ MockBackend, BaseRequestOptions ]
                             }),
                             OpenWeatherApi]);

  it('can instantiate',
     inject([ OpenWeatherApi ],
            (service: OpenWeatherApi) => { expect(service).to.be.exist; }));

  xdescribe('getWeatherForCity', () => {
    beforeEach(inject([ MockBackend ], (backend: MockBackend) => {
      backend.connections.subscribe((c: MockConnection) => {
        c.mockRespond(new Response(
          new ResponseOptions({ status : 200, body : { 'city' : 'Berlin' } })));
      });
    }));

    it('should return the mock data',
       async(inject([ OpenWeatherApi ], (service: OpenWeatherApi) => {
         service.getWeatherForCity('Berlin').toPromise().then(
           resp => { expect(resp).to.exist; });
       })));
  });
});
開發者ID:luhmann,項目名稱:ng2-webpack-weather-widget,代碼行數:29,代碼來源:open-weather-api.service.spec.ts

示例4: describe

describe('AppComponent', () => {
  let builder: TestComponentBuilder;

  beforeEach(inject([TestComponentBuilder], (tcb: TestComponentBuilder) => {
    builder = tcb.overrideProviders(AppComponent, []);
  }));

  it("can create", async(() => {
    builder.createAsync(AppComponent)
      .then(fixture => {
        assert(!!fixture);
      });
  }));

  it("should has text: 'My First Angular 2 App'", async(() => {
    builder.createAsync(AppComponent)
      .then(fixture => {
        let el = fixture.debugElement;
        assert(el.query(By.css("h1")).nativeElement.innerHTML === "My First Angular 2 App");
      });
  }));

  it("should has text: 'My Test'", async(() => {
    builder.createAsync(AppComponent)
      .then(fixture => {
        let el = fixture.debugElement;
        assert(el.query(By.css("p")).nativeElement.innerHTML === "My Test");
      });
  }));

  it("should fail", async(() => {
    let app = new AppComponent();
    let num = app.getNumber();
    assert(num === 101);
  }));
});
開發者ID:ovrmrw,項目名稱:angular2-testing-lite-5min-sample,代碼行數:36,代碼來源:app.spec.ts

示例5: resetBaseTestProviders

import "zone.js/dist/async-test";
import "rxjs/add/operator/toPromise";

import {assert} from "./test_util";
import {describe, it} from "angular2-testing-lite/mocha";
import {resetBaseTestProviders, setBaseTestProviders} from "angular2-testing-lite/core";
import {TEST_BROWSER_STATIC_PLATFORM_PROVIDERS, ADDITIONAL_TEST_BROWSER_PROVIDERS} from "@angular/platform-browser/testing/browser_static";
import {BROWSER_APP_DYNAMIC_PROVIDERS} from "@angular/platform-browser-dynamic";

resetBaseTestProviders();
setBaseTestProviders(TEST_BROWSER_STATIC_PLATFORM_PROVIDERS, [BROWSER_APP_DYNAMIC_PROVIDERS, ADDITIONAL_TEST_BROWSER_PROVIDERS]);

describe("dummy", () => {
  it("dummy", () => {
    assert.ok(true);
  });
});

import "./app/app-root.spec";
import "./app/components/about/about.spec";
import "./app/components/home/home.spec";
import "./app/components/repo-browser/repo-browser.spec";
import "./app/components/repo-detail/repo-detail.spec";
import "./app/components/repo-list/repo-list.spec";
import "./app/services/github.spec";
開發者ID:laco0416,項目名稱:angular2-seed,代碼行數:25,代碼來源:app.spec.ts


注:本文中的angular2-testing-lite/mocha.describe函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。