当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript TestSupport.mock_request_count函数代码示例

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


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

示例1: expect

            .then(() => {
              expect(mock_request_count()).to.equal(1);

              resource.invalidate({ foo: 123, noFetchGet: true });

              expect(store.invalidate.callCount).to.equal(1);
              expect(store.invalidate.getCall(0).args[1]).to.deep.equal({
                foo: 123,
                noFetchGet: true,
                invoker: resource
              });
              expect(resource.status).to.equal(IStatus.stale);
              expect(resource.timestamp).to.equal(ITimestamp.stale);
              expect(mock_request_count()).to.equal(1);
            })
开发者ID:netarc,项目名称:refrax,代码行数:15,代码来源:resource.spec.ts

示例2: it

    it('should look and behave like a Resource', () => {
      const onLoad = spy();
      const onChange = spy();
      const store = schema.__node.definition.storeMap.getOrCreate('user');
      spy(store, 'once');

      const resource = new Resource(schema.users);

      expect(resource)
        .to.be.instanceof(Resource);
      expect(resource)
        .to.have.property('timestamp')
          .that.equals(ITimestamp.loading);
      expect(resource)
        .to.have.property('status')
          .that.equals(IStatus.stale);
      expect(resource)
        .to.have.property('data')
          .that.equals(null);
      expect(resource)
        .to.have.property('_dispatchLoad')
          .that.is.a('function');

      resource.on('load', onLoad);
      resource.on('change', onChange);
      expect(store.once.callCount).to.equal(0);
      expect(mock_request_count()).to.equal(0);
      expect(onLoad.callCount).to.equal(0);
      expect(onChange.callCount).to.equal(0);

      return delay_for_resource_request(resource)()
        .then(() => {
          expect(mock_request_count()).to.equal(1);
          expect(onLoad.callCount).to.equal(1);
          expect(onChange.callCount).to.equal(1);
          expect(resource.data).to.deep.equal(dataCollectionUsers);
          expect(resource.status).to.equal(IStatus.complete);
          expect(resource.timestamp).to.be.greaterThan(ITimestamp.loading);
          expect(store.once.callCount).to.equal(0);

          const descriptor = new ResourceDescriptor(null, IActionType.get, schema.users.__stack);
          store.updateResource(descriptor, dataCollectionUsersUpdate, IStatus.complete);

          expect(onLoad.callCount).to.equal(1);
          expect(onChange.callCount).to.equal(2);
          expect(resource.data).to.deep.equal(dataCollectionUsersUpdate);
          expect(resource.status).to.equal(IStatus.complete);
          expect(resource.timestamp).to.be.greaterThan(ITimestamp.loading);
        });
    });
开发者ID:netarc,项目名称:refrax,代码行数:50,代码来源:resource.spec.ts

示例3: mock_get

              .then(() => {
                mock_get('/users', dataCollectionUsers);

                expect(mock_request_count()).to.equal(0);

                // re-enable fetch get
                resource._options.noFetchGet = false;

                const result = resource._fetchFragment({ noFetchGet: true });
                expect(result).is.instanceof(FragmentResult);

                return delay_for()()
                  .then(() => {
                    expect(mock_request_count()).to.equal(0);
                  });
              });
开发者ID:netarc,项目名称:refrax,代码行数:16,代码来源:resource.spec.ts


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