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


TypeScript TestSupport.mock_get函數代碼示例

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


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

示例1: beforeEach

  beforeEach(() => {
    mock_reset();
    mock_get('/users', dataCollectionUsers);

    schema = createSchema();
    schema.addLeaf(createSchemaCollection('users'));
  });
開發者ID:netarc,項目名稱:refrax,代碼行數:7,代碼來源:resource.spec.ts

示例2: it

          it('should correctly fetch', () => {
            mock_get('/rules', dataRules);

            return invokeTestHelper(IActionType.get, schema.rules.__stack, {
              expectedSignal: dataRules
            });
          });
開發者ID:netarc,項目名稱:refrax,代碼行數:7,代碼來源:XHRAdapter.spec.ts

示例3: expect

          .then(() => {
            expect(resource.hasData()).to.equal(true);

            mock_get('/users', dataCollectionUsers);
            resource.get();

            expect(resource.hasData()).to.equal(true);

            return wait_for_promise(() => resource.status === IStatus.complete)
              .then(() => {
                expect(resource.hasData()).to.equal(true);
              });
          });
開發者ID:netarc,項目名稱:refrax,代碼行數:13,代碼來源:resource.spec.ts

示例4: it

        it('should invoke a `get` descriptor', () => {
          const resource = new Resource(schema.users, new RefraxOptions({ noFetchGet: true }));

          mock_get('/users', dataCollectionUsers);

          const fragment = resource._fetchFragment({ noFetchGet: true, fragmentOnly: true }) as FragmentResult;
          expect(fragment.data).to.equal(null);

          return resource.get().then(([result, _response, _descriptor]: TRequestResult) => {
            expect(result).is.instanceof(FragmentResult);
            expect(result.data).to.deep.equal(dataCollectionUsers);
          });
        });
開發者ID:netarc,項目名稱:refrax,代碼行數:13,代碼來源:resource.spec.ts

示例5: 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

示例6: it

      it('properly updates collections when mutated', () => {
        mock_get('/users', dataCollectionUsers1);

        const resourceUsers = new Resource(schema.users);
        const mutableUser = new MutableResource(schema.users.user.withParams({
          userId: 1
        }));

        expect(resourceUsers).to.deep.match({
          data: null,
          status: IStatus.stale,
          timestamp: ITimestamp.loading
        });

        return delay_for_resource_request(resourceUsers)()
          .then(() => {
            expect(resourceUsers).to.deep.match({
              data: dataCollectionUsers1,
              status: IStatus.complete,
              timestamp: (val: number) => val > ITimestamp.loading
            });

            mock_put('/users/1', { id: 1, name: 'bob foo' });
            const promiseUpdate = mutableUser.update({ name: 'bob foo' });

            // The `touch` event from our `update` does not affect the collection
            expect(resourceUsers).to.deep.match({
              data: dataCollectionUsers1,
              status: IStatus.complete,
              timestamp: (val: number) => val > ITimestamp.loading
            });

            return promiseUpdate;
          })
          .then(() => {
            // The `update` event from our `update` action should update the collection
            expect(resourceUsers).to.deep.match({
              data: [
                { id: 1, name: 'bob foo' },
                dataElement2
              ],
              status: IStatus.complete,
              timestamp: (val: number) => val > ITimestamp.loading
            });
          });
      });
開發者ID:netarc,項目名稱:refrax,代碼行數:46,代碼來源:mutableResource.spec.ts


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