• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript testing_internal.it函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中angular2/testing_internal.it函数的典型用法代码示例。如果您正苦于以下问题:TypeScript it函数的具体用法?TypeScript it怎么用?TypeScript it使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了it函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: describe

    describe('loadTemplate', () => {
      describe('inline template', () => {
        it('should store the template',
           inject(
               [AsyncTestCompleter, TemplateNormalizer],
               (async, normalizer: TemplateNormalizer) => {
                 normalizer
                     .normalizeTemplate(dirType, new CompileTemplateMetadata({
                                          encapsulation: null,
                                          template: 'a',
                                          templateUrl: null,
                                          styles: [],
                                          styleUrls: ['test.css']
                                        }))
                     .then((template: CompileTemplateMetadata) => {
                       expect(template.template).toEqual('a');
                       expect(template.templateUrl).toEqual('package:some/module/a.js');
                       async.done();
                     });
               }));

        it('should resolve styles on the annotation against the moduleUrl',
           inject(
               [AsyncTestCompleter, TemplateNormalizer],
               (async, normalizer: TemplateNormalizer) => {
                 normalizer
                     .normalizeTemplate(dirType, new CompileTemplateMetadata({
                                          encapsulation: null,
                                          template: '',
                                          templateUrl: null,
                                          styles: [],
                                          styleUrls: ['test.css']
                                        }))
                     .then((template: CompileTemplateMetadata) => {
                       expect(template.styleUrls).toEqual(['package:some/module/test.css']);
                       async.done();
                     });
               }));

        it('should resolve styles in the template against the moduleUrl',
           inject(
               [AsyncTestCompleter, TemplateNormalizer],
               (async, normalizer: TemplateNormalizer) => {
                 normalizer
                     .normalizeTemplate(dirType, new CompileTemplateMetadata({
                                          encapsulation: null,
                                          template: '<style>@import test.css</style>',
                                          templateUrl: null,
                                          styles: [],
                                          styleUrls: []
                                        }))
                     .then((template: CompileTemplateMetadata) => {
                       expect(template.styleUrls).toEqual(['package:some/module/test.css']);
                       async.done();
                     });
               }));
      });

      describe('templateUrl', () => {

        it('should load a template from a url that is resolved against moduleUrl',
           inject(
               [AsyncTestCompleter, TemplateNormalizer, XHR],
               (async, normalizer: TemplateNormalizer, xhr: MockXHR) => {
                 xhr.expect('package:some/module/sometplurl.html', 'a');
                 normalizer
                     .normalizeTemplate(dirType, new CompileTemplateMetadata({
                                          encapsulation: null,
                                          template: null,
                                          templateUrl: 'sometplurl.html',
                                          styles: [],
                                          styleUrls: ['test.css']
                                        }))
                     .then((template: CompileTemplateMetadata) => {
                       expect(template.template).toEqual('a');
                       expect(template.templateUrl).toEqual('package:some/module/sometplurl.html');
                       async.done();
                     });
                 xhr.flush();
               }));

        it('should resolve styles on the annotation against the moduleUrl',
           inject(
               [AsyncTestCompleter, TemplateNormalizer, XHR],
               (async, normalizer: TemplateNormalizer, xhr: MockXHR) => {
                 xhr.expect('package:some/module/tpl/sometplurl.html', '');
                 normalizer
                     .normalizeTemplate(dirType, new CompileTemplateMetadata({
                                          encapsulation: null,
                                          template: null,
                                          templateUrl: 'tpl/sometplurl.html',
                                          styles: [],
                                          styleUrls: ['test.css']
                                        }))
                     .then((template: CompileTemplateMetadata) => {
                       expect(template.styleUrls).toEqual(['package:some/module/test.css']);
                       async.done();
                     });
                 xhr.flush();
               }));
//.........这里部分代码省略.........
开发者ID:LordBinary,项目名称:angular,代码行数:101,代码来源:template_normalizer_spec.ts


示例2: describe

  describe('run', () => {
    it('should return the body return value from run', inject([AsyncTestCompleter], (async) => {
         macroTask(() => { expect(_zone.run(() => { return 6; })).toEqual(6); });

         macroTask(() => { async.done(); });
       }), testTimeout);

    it('should call onUnstable and onMicrotaskEmpty', inject([AsyncTestCompleter], (async) => {
         runNgZoneNoLog(() => macroTask(_log.fn('run')));
         macroTask(() => {
           expect(_log.result()).toEqual('onUnstable; run; onMicrotaskEmpty; onStable');
           async.done();
         });
       }), testTimeout);

    it('should call onStable once at the end of event', inject([AsyncTestCompleter], (async) => {
         // The test is set up in a way that causes the zone loop to run onMicrotaskEmpty twice
         // then verified that onStable is only called once at the end

         runNgZoneNoLog(() => macroTask(_log.fn('run')));

         var times = 0;
         ObservableWrapper.subscribe(_zone.onMicrotaskEmpty, (_) => {
           times++;
           _log.add(`onMicrotaskEmpty ${times}`);
           if (times < 2) {
             // Scheduling a microtask causes a second digest
             runNgZoneNoLog(() => { scheduleMicroTask(() => {}); });
           }
         });

         macroTask(() => {
           expect(_log.result())
               .toEqual(
                   'onUnstable; run; onMicrotaskEmpty; onMicrotaskEmpty 1; ' +
                   'onMicrotaskEmpty; onMicrotaskEmpty 2; onStable');
           async.done();
         }, resultTimer);
       }), testTimeout);

    it('should call standalone onStable', inject([AsyncTestCompleter], (async) => {
         runNgZoneNoLog(() => macroTask(_log.fn('run')));

         macroTask(() => {
           expect(_log.result()).toEqual('onUnstable; run; onMicrotaskEmpty; onStable');
           async.done();
         }, resultTimer);
       }), testTimeout);

    xit('should run subscriber listeners in the subscription zone (outside)',
        inject([AsyncTestCompleter], (async) => {
          // Each subscriber fires a microtask outside the Angular zone. The test
          // then verifies that those microtasks do not cause additional digests.

          var turnStart = false;
          ObservableWrapper.subscribe(_zone.onUnstable, (_) => {
            if (turnStart) throw 'Should not call this more than once';
            _log.add('onUnstable');
            scheduleMicroTask(() => {});
            turnStart = true;
          });

          var turnDone = false;
          ObservableWrapper.subscribe(_zone.onMicrotaskEmpty, (_) => {
            if (turnDone) throw 'Should not call this more than once';
            _log.add('onMicrotaskEmpty');
            scheduleMicroTask(() => {});
            turnDone = true;
          });

          var eventDone = false;
          ObservableWrapper.subscribe(_zone.onStable, (_) => {
            if (eventDone) throw 'Should not call this more than once';
            _log.add('onStable');
            scheduleMicroTask(() => {});
            eventDone = true;
          });

          macroTask(() => { _zone.run(_log.fn('run')); });

          macroTask(() => {
            expect(_log.result()).toEqual('onUnstable; run; onMicrotaskEmpty; onStable');
            async.done();
          }, resultTimer);
        }), testTimeout);

    it('should run subscriber listeners in the subscription zone (inside)',
       inject([AsyncTestCompleter], (async) => {
         runNgZoneNoLog(() => macroTask(_log.fn('run')));

         // the only practical use-case to run a callback inside the zone is
         // change detection after "onMicrotaskEmpty". That's the only case tested.
         var turnDone = false;
         ObservableWrapper.subscribe(_zone.onMicrotaskEmpty, (_) => {
           _log.add('onMyMicrotaskEmpty');
           if (turnDone) return;
           _zone.run(() => { scheduleMicroTask(() => {}); });
           turnDone = true;
         });

//.........这里部分代码省略.........
开发者ID:LordBinary,项目名称:angular,代码行数:101,代码来源:ng_zone_spec.ts


示例3: it

 () => { it("should parse function calls", () => { checkAction("fn()(1, 2)"); }); });
开发者ID:ProjectFrank,项目名称:angular,代码行数:1,代码来源:parser_spec.ts


示例4: describe

  describe('router bootstrap', () => {
    beforeEachProviders(() => [
      ROUTER_PROVIDERS,
      provide(LocationStrategy, {useClass: MockLocationStrategy}),
      provide(ApplicationRef, {useClass: MockApplicationRef})
    ]);

    // do not refactor out the `bootstrap` functionality. We still want to
    // keep this test around so we can ensure that bootstrapping a router works
    it('should bootstrap a simple app', inject([AsyncTestCompleter], (async) => {
         var fakeDoc = DOM.createHtmlDocument();
         var el = DOM.createElement('app-cmp', fakeDoc);
         DOM.appendChild(fakeDoc.body, el);

         bootstrap(AppCmp,
                   [
                     ROUTER_PROVIDERS,
                     provide(ROUTER_PRIMARY_COMPONENT, {useValue: AppCmp}),
                     provide(LocationStrategy, {useClass: MockLocationStrategy}),
                     provide(DOCUMENT, {useValue: fakeDoc}),
                     provide(Console, {useClass: DummyConsole})
                   ])
             .then((applicationRef) => {
               var router = applicationRef.hostComponent.router;
               router.subscribe((_) => {
                 expect(el).toHaveText('outer { hello }');
                 expect(applicationRef.hostComponent.location.path()).toEqual('');
                 async.done();
               });
             });
       }));

    describe('broken app', () => {
      beforeEachProviders(() => [provide(ROUTER_PRIMARY_COMPONENT, {useValue: BrokenAppCmp})]);

      it('should rethrow exceptions from component constructors',
         inject([AsyncTestCompleter, TestComponentBuilder], (async, tcb: TestComponentBuilder) => {
           tcb.createAsync(AppCmp).then((fixture) => {
             var router = fixture.debugElement.componentInstance.router;
             PromiseWrapper.catchError(router.navigateByUrl('/cause-error'), (error) => {
               expect(error).toContainError('oops!');
               async.done();
             });
           });
         }));
    });

    describe('back button app', () => {
      beforeEachProviders(() => [provide(ROUTER_PRIMARY_COMPONENT, {useValue: HierarchyAppCmp})]);

      it('should change the url without pushing a new history state for back navigations',
         inject([AsyncTestCompleter, TestComponentBuilder], (async, tcb: TestComponentBuilder) => {

           tcb.createAsync(HierarchyAppCmp)
               .then((fixture) => {
                 var router = fixture.debugElement.componentInstance.router;
                 var position = 0;
                 var flipped = false;
                 var history = [
                   ['/parent/child', 'root { parent { hello } }', '/super-parent/child'],
                   ['/super-parent/child', 'root { super-parent { hello2 } }', '/parent/child'],
                   ['/parent/child', 'root { parent { hello } }', false]
                 ];

                 router.subscribe((_) => {
                   var location = fixture.debugElement.componentInstance.location;
                   var element = fixture.debugElement.nativeElement;
                   var path = location.path();

                   var entry = history[position];

                   expect(path).toEqual(entry[0]);
                   expect(element).toHaveText(entry[1]);

                   var nextUrl = entry[2];
                   if (nextUrl == false) {
                     flipped = true;
                   }

                   if (flipped && position == 0) {
                     async.done();
                     return;
                   }

                   position = position + (flipped ? -1 : 1);
                   if (flipped) {
                     location.back();
                   } else {
                     router.navigateByUrl(nextUrl);
                   }
                 });

                 router.navigateByUrl(history[0][0]);
               });
         }), 1000);
    });

    describe('hierarchical app', () => {
      beforeEachProviders(
          () => { return [provide(ROUTER_PRIMARY_COMPONENT, {useValue: HierarchyAppCmp})]; });
//.........这里部分代码省略.........
开发者ID:ASLA1899,项目名称:angular,代码行数:101,代码来源:bootstrap_spec.ts


示例5: describe

  describe('MessageExtractor', () => {
    let extractor: MessageExtractor;

    beforeEach(() => {
      let htmlParser = new HtmlParser();
      var parser = new Parser(new Lexer());
      extractor = new MessageExtractor(htmlParser, parser);
    });

    it('should extract from elements with the i18n attr', () => {
      let res = extractor.extract("<div i18n='meaning|desc'>message</div>", "someurl");
      expect(res.messages).toEqual([new Message("message", 'meaning', 'desc')]);
    });

    it('should extract from elements with the i18n attr without a desc', () => {
      let res = extractor.extract("<div i18n='meaning'>message</div>", "someurl");
      expect(res.messages).toEqual([new Message("message", 'meaning', null)]);
    });

    it('should extract from elements with the i18n attr without a meaning', () => {
      let res = extractor.extract("<div i18n>message</div>", "someurl");
      expect(res.messages).toEqual([new Message("message", null, null)]);
    });

    it('should extract from attributes', () => {
      let res = extractor.extract(`
        <div
          title1='message1' i18n-title1='meaning1|desc1'
          title2='message2' i18n-title2='meaning2|desc2'>
        </div>
      `,
                                  "someurl");

      expect(res.messages)
          .toEqual([
            new Message("message1", "meaning1", "desc1"),
            new Message("message2", "meaning2", "desc2")
          ]);
    });

    it('should extract from partitions', () => {
      let res = extractor.extract(`
         <!-- i18n: meaning1|desc1 -->message1<!-- /i18n -->
         <!-- i18n: meaning2|desc2 -->message2<!-- /i18n -->`,
                                  "someUrl");

      expect(res.messages)
          .toEqual([
            new Message("message1", "meaning1", "desc1"),
            new Message("message2", "meaning2", "desc2")
          ]);
    });

    it('should ignore other comments', () => {
      let res = extractor.extract(`
         <!-- i18n: meaning1|desc1 --><!-- other -->message1<!-- /i18n -->`,
                                  "someUrl");

      expect(res.messages).toEqual([new Message("message1", "meaning1", "desc1")]);
    });

    it('should replace interpolation with placeholders (text nodes)', () => {
      let res = extractor.extract("<div i18n>Hi {{one}} and {{two}}</div>", "someurl");
      expect(res.messages)
          .toEqual(
              [new Message('<ph name="t0">Hi <ph name="0"/> and <ph name="1"/></ph>', null, null)]);
    });

    it('should replace interpolation with placeholders (attributes)', () => {
      let res =
          extractor.extract("<div title='Hi {{one}} and {{two}}' i18n-title></div>", "someurl");
      expect(res.messages)
          .toEqual([new Message('Hi <ph name="0"/> and <ph name="1"/>', null, null)]);
    });

    it("should handle html content", () => {
      let res = extractor.extract(
          '<div i18n><div attr="value">zero<div>one</div></div><div>two</div></div>', "someurl");
      expect(res.messages)
          .toEqual([
            new Message('<ph name="e0">zero<ph name="e2">one</ph></ph><ph name="e4">two</ph>', null,
                        null)
          ]);
    });

    it("should handle html content with interpolation", () => {
      let res =
          extractor.extract('<div i18n><div>zero{{a}}<div>{{b}}</div></div></div>', "someurl");
      expect(res.messages)
          .toEqual([
            new Message(
                '<ph name="e0"><ph name="t1">zero<ph name="0"/></ph><ph name="e2"><ph name="t3"><ph name="0"/></ph></ph></ph>',
                null, null)
          ]);
    });

    it("should extract from nested elements", () => {
      let res = extractor.extract(
          '<div title="message1" i18n-title="meaning1|desc1"><div i18n="meaning2|desc2">message2</div></div>',
          "someurl");
//.........这里部分代码省略.........
开发者ID:1186792881,项目名称:angular,代码行数:101,代码来源:message_extractor_spec.ts


示例6: describe

    describe('short-circuit', () => {
      it('should not use short-circuitable records', () => {
        var records = [
          r("sknot", [], 0, 1, {mode: RecordType.SkipRecordsIfNot, fixedArgs: [3]}),
          r("a", [], 0, 2),
          r("sk", [], 0, 3, {mode: RecordType.SkipRecords, fixedArgs: [4]}),
          r("b", [], 0, 4),
          r("cond", [2, 4], 0, 5),
          r("a", [], 0, 6),
          r("b", [], 0, 7),
        ];

        expect(coalesce(records)).toEqual(records);
      });

      it('should not use short-circuitable records from nested short-circuits', () => {
        var records = [
          r("sknot outer", [], 0, 1, {mode: RecordType.SkipRecordsIfNot, fixedArgs: [7]}),
          r("sknot inner", [], 0, 2, {mode: RecordType.SkipRecordsIfNot, fixedArgs: [4]}),
          r("a", [], 0, 3),
          r("sk inner", [], 0, 4, {mode: RecordType.SkipRecords, fixedArgs: [5]}),
          r("b", [], 0, 5),
          r("cond-inner", [3, 5], 0, 6),
          r("sk outer", [], 0, 7, {mode: RecordType.SkipRecords, fixedArgs: [8]}),
          r("c", [], 0, 8),
          r("cond-outer", [6, 8], 0, 9),
          r("a", [], 0, 10),
          r("b", [], 0, 11),
          r("c", [], 0, 12),
        ];

        expect(coalesce(records)).toEqual(records);
      });

      it('should collapse the true branch', () => {
        var rs = coalesce([
          r("a", [], 0, 1),
          r("sknot", [], 0, 2, {mode: RecordType.SkipRecordsIfNot, fixedArgs: [4]}),
          r("a", [], 0, 3),
          r("sk", [], 0, 4, {mode: RecordType.SkipRecords, fixedArgs: [6]}),
          r("a", [], 0, 5),
          r("b", [], 5, 6),
          r("cond", [3, 6], 0, 7),
        ]);

        expect(rs).toEqual([
          r("a", [], 0, 1),
          r("sknot", [], 0, 2, {mode: RecordType.SkipRecordsIf, fixedArgs: [3]}),
          r("b", [], 1, 3),
          r("cond", [1, 3], 0, 4),
        ]);
      });

      it('should collapse the false branch', () => {
        var rs = coalesce([
          r("a", [], 0, 1),
          r("sknot", [], 0, 2, {mode: RecordType.SkipRecordsIfNot, fixedArgs: [5]}),
          r("a", [], 0, 3),
          r("b", [], 3, 4),
          r("sk", [], 0, 5, {mode: RecordType.SkipRecords, fixedArgs: [6]}),
          r("a", [], 0, 6),
          r("cond", [4, 6], 0, 7),
        ]);

        expect(rs).toEqual([
          r("a", [], 0, 1),
          r("sknot", [], 0, 2, {mode: RecordType.SkipRecordsIfNot, fixedArgs: [3]}),
          r("b", [], 1, 3),
          r("cond", [3, 1], 0, 4),
        ]);
      });

      it('should optimize skips', () => {
        var rs = coalesce([
          // skipIfNot(1) + skip(N) -> skipIf(+N)
          r("sknot", [], 0, 1, {mode: RecordType.SkipRecordsIfNot, fixedArgs: [2]}),
          r("sk", [], 0, 2, {mode: RecordType.SkipRecords, fixedArgs: [3]}),
          r("a", [], 0, 3),
          // skipIf(1) + skip(N) -> skipIfNot(N)
          r("skif", [], 0, 4, {mode: RecordType.SkipRecordsIf, fixedArgs: [5]}),
          r("sk", [], 0, 5, {mode: RecordType.SkipRecords, fixedArgs: [6]}),
          r("b", [], 0, 6),
          // remove empty skips
          r("sknot", [], 0, 7, {mode: RecordType.SkipRecordsIfNot, fixedArgs: [7]}),
          r("skif", [], 0, 8, {mode: RecordType.SkipRecordsIf, fixedArgs: [8]}),
          r("sk", [], 0, 9, {mode: RecordType.SkipRecords, fixedArgs: [9]}),
          r("end", [], 0, 10),
        ]);

        expect(rs).toEqual([
          r("sknot", [], 0, 1, {mode: RecordType.SkipRecordsIf, fixedArgs: [2]}),
          r("a", [], 0, 2),
          r("skif", [], 0, 3, {mode: RecordType.SkipRecordsIfNot, fixedArgs: [4]}),
          r("b", [], 0, 4),
          r("end", [], 0, 5),
        ]);
      });
    });
开发者ID:1186792881,项目名称:angular,代码行数:98,代码来源:coalesce_spec.ts


示例7: describe

  describe('routerLink directive', function() {
    var tcb: TestComponentBuilder;

    beforeEachProviders(() => [
      provide(Location, {useValue: makeDummyLocation()}),
      provide(Router, {useValue: makeDummyRouter()})
    ]);

    beforeEach(inject([TestComponentBuilder], (tcBuilder) => { tcb = tcBuilder; }));

    it('should update a[href] attribute', inject([AsyncTestCompleter], (async) => {

         tcb.createAsync(TestComponent)
             .then((testComponent) => {
               testComponent.detectChanges();
               let anchorElement =
                   testComponent.debugElement.query(By.css('a.detail-view')).nativeElement;
               expect(DOM.getAttribute(anchorElement, 'href')).toEqual('detail');
               async.done();
             });
       }));


    it('should call router.navigate when a link is clicked',
       inject([AsyncTestCompleter, Router], (async, router) => {

         tcb.createAsync(TestComponent)
             .then((testComponent) => {
               testComponent.detectChanges();
               // TODO: shouldn't this be just 'click' rather than '^click'?
               testComponent.debugElement.query(By.css('a.detail-view'))
                   .triggerEventHandler('click', null);
               expect(router.spy('navigateByInstruction')).toHaveBeenCalledWith(dummyInstruction);
               async.done();
             });
       }));

    it('should call router.navigate when a link is clicked if target is _self',
       inject([AsyncTestCompleter, Router], (async, router) => {

         tcb.createAsync(TestComponent)
             .then((testComponent) => {
               testComponent.detectChanges();
               testComponent.debugElement.query(By.css('a.detail-view-self'))
                   .triggerEventHandler('click', null);
               expect(router.spy('navigateByInstruction')).toHaveBeenCalledWith(dummyInstruction);
               async.done();
             });
       }));

    it('should NOT call router.navigate when a link is clicked if target is set to other than _self',
       inject([AsyncTestCompleter, Router], (async, router) => {

         tcb.createAsync(TestComponent)
             .then((testComponent) => {
               testComponent.detectChanges();
               testComponent.debugElement.query(By.css('a.detail-view-blank'))
                   .triggerEventHandler('click', null);
               expect(router.spy('navigateByInstruction')).not.toHaveBeenCalled();
               async.done();
             });
       }));
  });
开发者ID:844496869,项目名称:angular,代码行数:63,代码来源:router_link_spec.ts


示例8: describe

  describe('chrome driver extension', () => {
    var CHROME44_USER_AGENT =
        '"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.0 Safari/537.36"';
    var CHROME45_USER_AGENT =
        '"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2499.0 Safari/537.36"';

    var log;
    var extension;

    var blinkEvents = new TraceEventFactory('blink.console', 'pid0');
    var v8Events = new TraceEventFactory('v8', 'pid0');
    var v8EventsOtherProcess = new TraceEventFactory('v8', 'pid1');
    var chromeTimelineEvents =
        new TraceEventFactory('disabled-by-default-devtools.timeline', 'pid0');
    var chrome45TimelineEvents = new TraceEventFactory('devtools.timeline', 'pid0');
    var chromeTimelineV8Events = new TraceEventFactory('devtools.timeline,v8', 'pid0');
    var chromeBlinkTimelineEvents = new TraceEventFactory('blink,devtools.timeline', 'pid0');
    var benchmarkEvents = new TraceEventFactory('benchmark', 'pid0');
    var normEvents = new TraceEventFactory('timeline', 'pid0');

    function createExtension(perfRecords = null, userAgent = null,
                             messageMethod = 'Tracing.dataCollected') {
      if (isBlank(perfRecords)) {
        perfRecords = [];
      }
      if (isBlank(userAgent)) {
        userAgent = CHROME44_USER_AGENT;
      }
      log = [];
      extension = Injector.resolveAndCreate([
                            ChromeDriverExtension.BINDINGS,
                            bind(WebDriverAdapter)
                                .toValue(new MockDriverAdapter(log, perfRecords, messageMethod)),
                            bind(Options.USER_AGENT).toValue(userAgent)
                          ])
                      .get(ChromeDriverExtension);
      return extension;
    }

    it('should force gc via window.gc()', inject([AsyncTestCompleter], (async) => {
         createExtension().gc().then((_) => {
           expect(log).toEqual([['executeScript', 'window.gc()']]);
           async.done();
         });
       }));

    it('should mark the timeline via console.time()', inject([AsyncTestCompleter], (async) => {
         createExtension()
             .timeBegin('someName')
             .then((_) => {
               expect(log).toEqual([['executeScript', `console.time('someName');`]]);
               async.done();
             });
       }));

    it('should mark the timeline via console.timeEnd()', inject([AsyncTestCompleter], (async) => {
         createExtension()
             .timeEnd('someName')
             .then((_) => {
               expect(log).toEqual([['executeScript', `console.timeEnd('someName');`]]);
               async.done();
             });
       }));

    it('should mark the timeline via console.time() and console.timeEnd()',
       inject([AsyncTestCompleter], (async) => {
         createExtension()
             .timeEnd('name1', 'name2')
             .then((_) => {
               expect(log)
                   .toEqual([['executeScript', `console.timeEnd('name1');console.time('name2');`]]);
               async.done();
             });
       }));

    describe('readPerfLog Chrome44', () => {
      it('should normalize times to ms and forward ph and pid event properties',
         inject([AsyncTestCompleter], (async) => {
           createExtension([chromeTimelineEvents.complete('FunctionCall', 1100, 5500, null)])
               .readPerfLog()
               .then((events) => {
                 expect(events).toEqual([
                   normEvents.complete('script', 1.1, 5.5, null),
                 ]);
                 async.done();
               });
         }));

      it('should normalize "tdur" to "dur"', inject([AsyncTestCompleter], (async) => {
           var event = chromeTimelineEvents.create('X', 'FunctionCall', 1100, null);
           event['tdur'] = 5500;
           createExtension([event]).readPerfLog().then((events) => {
             expect(events).toEqual([
               normEvents.complete('script', 1.1, 5.5, null),
             ]);
             async.done();
           });
         }));

      it('should report FunctionCall events as "script"', inject([AsyncTestCompleter], (async) => {
//.........这里部分代码省略.........
开发者ID:TedSander,项目名称:angular,代码行数:101,代码来源:chrome_driver_extension_spec.ts



注:本文中的angular2/testing_internal.it函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript testing_internal.tick函数代码示例发布时间:2022-05-25
下一篇:
TypeScript testing_internal.isInInnerZone函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap