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


TypeScript test_lib.xit函數代碼示例

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


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

示例1: describe

    describe('Promise', () => {
      it('should run asynchronous code', fakeAsync(() => {
           var thenRan = false;
           PromiseWrapper.resolve(null).then((_) => { thenRan = true; });

           expect(thenRan).toEqual(false);

           flushMicrotasks();
           expect(thenRan).toEqual(true);
         }));

      it('should run chained thens', fakeAsync(() => {
           var log = new Log();

           PromiseWrapper.resolve(null).then((_) => log.add(1)).then((_) => log.add(2));

           expect(log.result()).toEqual('');

           flushMicrotasks();
           expect(log.result()).toEqual('1; 2');
         }));

      it('should run Promise created in Promise', fakeAsync(() => {
           var log = new Log();

           PromiseWrapper.resolve(null).then((_) => {
             log.add(1);
             PromiseWrapper.resolve(null).then((_) => log.add(2));
           });

           expect(log.result()).toEqual('');

           flushMicrotasks();
           expect(log.result()).toEqual('1; 2');
         }));

      // TODO(vicb): check why this doesn't work in JS - linked to open issues on GH ?
      xit('should complain if the test throws an exception during async calls', () => {
        expect(() => {
          fakeAsync(() => {
            PromiseWrapper.resolve(null).then((_) => { throw new BaseException('async'); });
            flushMicrotasks();
          })();
        }).toThrowError('async');
      });

      it('should complain if a test throws an exception', () => {
        expect(() => { fakeAsync(() => { throw new BaseException('sync'); })(); })
            .toThrowError('sync');
      });

    });
開發者ID:CADBOT,項目名稱:angular,代碼行數:52,代碼來源:fake_async_spec.ts

示例2: describe

 describe("error handling", () => {
   xit("should wrap exceptions into ChangeDetectionError", () => {
     var pcd = createProtoChangeDetector();
     var cd = pcd.instantiate(new TestDispatcher(), [new BindingRecord(ast("invalidProp", "someComponent"), "a", 1)], null, []);
     cd.hydrate(null, null);
     try {
       cd.detectChanges();
       throw new BaseException("fail");
     } catch (e) {
       expect(e).toBeAnInstanceOf(ChangeDetectionError);
       expect(e.location).toEqual("invalidProp in someComponent");
     }
   });
 });
開發者ID:gdi2290,項目名稱:sample-Angular2,代碼行數:14,代碼來源:change_detection_spec.ts

示例3: describe

 describe("valueChanges", () => {
   var g,
       c1,
       c2;
   beforeEach(() => {
     c1 = new Control("old1");
     c2 = new Control("old2");
     g = new ControlGroup({
       "one": c1,
       "two": c2
     }, {"two": true});
   });
   it("should fire an event after the value has been updated", inject([AsyncTestCompleter], (async) => {
     ObservableWrapper.subscribe(g.valueChanges, (value) => {
       expect(g.value).toEqual({
         'one': 'new1',
         'two': 'old2'
       });
       expect(value).toEqual({
         'one': 'new1',
         'two': 'old2'
       });
       async.done();
     });
     c1.updateValue("new1");
   }));
   it("should fire an event after the control's observable fired an event", inject([AsyncTestCompleter], (async) => {
     var controlCallbackIsCalled = false;
     ObservableWrapper.subscribe(c1.valueChanges, (value) => {
       controlCallbackIsCalled = true;
     });
     ObservableWrapper.subscribe(g.valueChanges, (value) => {
       expect(controlCallbackIsCalled).toBe(true);
       async.done();
     });
     c1.updateValue("new1");
   }));
   it("should fire an event when a control is excluded", inject([AsyncTestCompleter], (async) => {
     ObservableWrapper.subscribe(g.valueChanges, (value) => {
       expect(value).toEqual({'one': 'old1'});
       async.done();
     });
     g.exclude("two");
   }));
   it("should fire an event when a control is included", inject([AsyncTestCompleter], (async) => {
     g.exclude("two");
     ObservableWrapper.subscribe(g.valueChanges, (value) => {
       expect(value).toEqual({
         'one': 'old1',
         'two': 'old2'
       });
       async.done();
     });
     g.include("two");
   }));
   it("should fire an event every time a control is updated", inject([AsyncTestCompleter], (async) => {
     var loggedValues = [];
     ObservableWrapper.subscribe(g.valueChanges, (value) => {
       ListWrapper.push(loggedValues, value);
       if (loggedValues.length == 2) {
         expect(loggedValues).toEqual([{
           "one": "new1",
           "two": "old2"
         }, {
           "one": "new1",
           "two": "new2"
         }]);
         async.done();
       }
     });
     c1.updateValue("new1");
     c2.updateValue("new2");
   }));
   xit("should not fire an event when an excluded control is updated", inject([AsyncTestCompleter], (async) => {}));
 });
開發者ID:gdi2290,項目名稱:sample-Angular2,代碼行數:75,代碼來源:model_spec.ts

示例4: describe


//.........這裏部分代碼省略.........
     rootEl = testbed.rootEl;
     rootProtoViewRef = testbed.rootProtoViewRef;
     eventPlugin = testbed.eventPlugin;
     compile = (template, directives) => testbed.compile(template, directives);
   }
   it('should create root views while using the given elements in place', () => {
     createRenderer();
     var viewRefs = renderer.createView(rootProtoViewRef);
     expect(viewRefs.length).toBe(1);
     expect(viewRefs[0].delegate.rootNodes[0]).toEqual(rootEl);
   });
   it('should add a static component', inject([AsyncTestCompleter], (async) => {
     createRenderer();
     var template = new Template({
       componentId: 'someComponent',
       inline: 'hello',
       directives: []
     });
     renderer.compile(template).then((pv) => {
       var mergedProtoViewRefs = renderer.mergeChildComponentProtoViews(rootProtoViewRef, [pv.render]);
       renderer.createView(mergedProtoViewRefs[0]);
       expect(rootEl).toHaveText('hello');
       async.done();
     });
   }));
   it('should add a a dynamic component', inject([AsyncTestCompleter], (async) => {
     createRenderer();
     var template = new Template({
       componentId: 'someComponent',
       inline: 'hello',
       directives: []
     });
     renderer.compile(template).then((pv) => {
       var rootViewRef = renderer.createView(rootProtoViewRef)[0];
       var childComponentViewRef = renderer.createView(pv.render)[0];
       renderer.setDynamicComponentView(rootViewRef, 0, childComponentViewRef);
       expect(rootEl).toHaveText('hello');
       async.done();
     });
   }));
   it('should update text nodes', inject([AsyncTestCompleter], (async) => {
     createRenderer();
     compile('{{a}}', [someComponent]).then((pvRefs) => {
       var viewRefs = renderer.createView(pvRefs[0]);
       renderer.setText(viewRefs[1], 0, 'hello');
       expect(rootEl).toHaveText('hello');
       async.done();
     });
   }));
   it('should update element properties', inject([AsyncTestCompleter], (async) => {
     createRenderer();
     compile('<input [value]="someProp">', []).then((pvRefs) => {
       var viewRefs = renderer.createView(pvRefs[0]);
       renderer.setElementProperty(viewRefs[1], 0, 'value', 'hello');
       expect(DOM.childNodes(rootEl)[0].value).toEqual('hello');
       async.done();
     });
   }));
   it('should add and remove views to and from containers', inject([AsyncTestCompleter], (async) => {
     createRenderer();
     compile('<template>hello</template>', []).then((pvRefs) => {
       var viewRef = renderer.createView(pvRefs[0])[1];
       var vcProtoViewRef = pvRefs[2];
       var vcRef = new ViewContainerRef(viewRef, 0);
       var childViewRef = renderer.createView(vcProtoViewRef)[0];
       expect(rootEl).toHaveText('');
       renderer.insertViewIntoContainer(vcRef, childViewRef);
       expect(rootEl).toHaveText('hello');
       renderer.detachViewFromContainer(vcRef, 0);
       expect(rootEl).toHaveText('');
       async.done();
     });
   }));
   it('should cache views', inject([AsyncTestCompleter], (async) => {
     createRenderer({viewCacheCapacity: 2});
     compile('<template>hello</template>', []).then((pvRefs) => {
       var vcProtoViewRef = pvRefs[2];
       var viewRef1 = renderer.createView(vcProtoViewRef)[0];
       renderer.destroyView(viewRef1);
       var viewRef2 = renderer.createView(vcProtoViewRef)[0];
       var viewRef3 = renderer.createView(vcProtoViewRef)[0];
       expect(viewRef2.delegate).toBe(viewRef1.delegate);
       expect(viewRef3.delegate).not.toBe(viewRef1.delegate);
       async.done();
     });
   }));
   xit('should handle events', inject([AsyncTestCompleter], (async) => {
     createRenderer();
     compile('<input (change)="$event.target.value">', []).then((pvRefs) => {
       var viewRef = renderer.createView(pvRefs[0])[1];
       var dispatcher = new LoggingEventDispatcher();
       renderer.setEventDispatcher(viewRef, dispatcher);
       var inputEl = DOM.childNodes(rootEl)[0];
       inputEl.value = 'hello';
       eventPlugin.dispatchEvent('change', new FakeEvent(inputEl));
       expect(dispatcher.log).toEqual([[0, 'change', ['hello']]]);
       async.done();
     });
   }));
 });
開發者ID:gdi2290,項目名稱:sample-Angular2,代碼行數:101,代碼來源:direct_dom_renderer_integration_spec.ts


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