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


TypeScript TestSupport.mock_reset函數代碼示例

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


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

示例1: beforeEach

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

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

示例2: beforeEach

      beforeEach(() => {
        mock_reset();

        schema = createSchema();
        schema.addLeaf(createSchemaCollection('users'));

        spy_defaultHandler = spy(processResponse, 'defaultHandler');
      });
開發者ID:netarc,項目名稱:refrax,代碼行數:8,代碼來源:processResponse.spec.ts

示例3: beforeEach

      beforeEach(() => {
        mutableUsers = new MutableResource(schema.users);
        store = expectedDescriptor.store = schema.__node.definition.storeMap.getOrCreate('user');

        spyMutableUsers_generateDescriptor = spy(mutableUsers, '_generateDescriptor');
        spyStore_touchResource = spy(store, 'touchResource');
        spyStore_updateResource = spy(store, 'updateResource');
        spyStore_destroyResource = spy(store, 'destroyResource');

        mock_reset();
        mock_put('/users', responseData);
      });
開發者ID:netarc,項目名稱:refrax,代碼行數:12,代碼來源:mutableResource.spec.ts

示例4: beforeEach

  beforeEach(() => {
    mock_reset();

    adapter = new XHRAdapter();
    schema = createSchema({ adapter });
    schema.addLeaf(createSchemaCollection('users'));
    schema.addLeaf(createSchemaResource('rules'));

    storeUsers = schema.__node.definition.storeMap.getOrCreate('user');
    spyUsers_touchResource = spy(storeUsers, 'touchResource');
    spyUsers_updateResource = spy(storeUsers, 'updateResource');

    storeRules = schema.__node.definition.storeMap.getOrCreate('rule');
    spyRules_touchResource = spy(storeRules, 'touchResource');
    spyRules_updateResource = spy(storeRules, 'updateResource');
  });
開發者ID:netarc,項目名稱:refrax,代碼行數:16,代碼來源:XHRAdapter.spec.ts

示例5: it

    it('should handle loading a failed request', () => {
      mock_reset();
      mock_get('/users', { error: 'foobar' }, 500);

      const onLoad = spy();
      const onChange = spy();
      const store = schema.__node.definition.storeMap.getOrCreate('user');
      spy(store, 'once');

      const resource = new Resource(schema.users);

      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(0);
          expect(onChange.callCount).to.equal(1);
          expect(resource.data).to.equal(null);
          expect(resource.status).to.equal(IStatus.stale);
          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,代碼行數:38,代碼來源:resource.spec.ts


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