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


TypeScript Sinon.SinonStatic類代碼示例

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


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

示例1: Schema

  hooks.beforeEach(() => {
    fetchStub = sinon.stub(self, 'fetch');
    schema = new Schema({
      models: {
        planet: {
          keys: {
            remoteId: {}
          },
          attributes: {
            name: { type: 'string' },
            classification: { type: 'string' },
            lengthOfDay: { type: 'number' }
          },
          relationships: {
            moons: { type: 'hasMany', model: 'moon', inverse: 'planet' },
            solarSystem: {
              type: 'hasOne',
              model: 'solarSystem',
              inverse: 'planets'
            }
          }
        },
        moon: {
          keys: {
            remoteId: {}
          },
          attributes: {
            name: { type: 'string' }
          },
          relationships: {
            planet: { type: 'hasOne', model: 'planet', inverse: 'moons' }
          }
        },
        solarSystem: {
          keys: {
            remoteId: {}
          },
          attributes: {
            name: { type: 'string' }
          },
          relationships: {
            planets: {
              type: 'hasMany',
              model: 'planet',
              inverse: 'solarSystem'
            }
          }
        }
      }
    });

    keyMap = new KeyMap();
    processor = new JSONAPIRequestProcessor({
      schema,
      keyMap,
      sourceName: 'foo'
    });
    processor.serializer.resourceKey = function() {
      return 'remoteId';
    };
  });
開發者ID:orbitjs,項目名稱:orbit.js,代碼行數:61,代碼來源:jsonapi-request-processor-test.ts

示例2: RequestStrategy

  hooks.beforeEach(() => {
    fetchStub = sinon.stub(self, 'fetch');

    schema = new Schema({
      models: {
        planet: {
          keys: {
            remoteId: {}
          },
          attributes: {
            name: { type: 'string' },
            classification: { type: 'string' },
            lengthOfDay: { type: 'number' }
          },
          relationships: {
            moons: { type: 'hasMany', model: 'moon', inverse: 'planet' },
            solarSystem: {
              type: 'hasOne',
              model: 'solarSystem',
              inverse: 'planets'
            }
          }
        },
        moon: {
          keys: {
            remoteId: {}
          },
          attributes: {
            name: { type: 'string' }
          },
          relationships: {
            planet: { type: 'hasOne', model: 'planet', inverse: 'moons' }
          }
        },
        solarSystem: {
          keys: {
            remoteId: {}
          },
          attributes: {
            name: { type: 'string' }
          },
          relationships: {
            planets: {
              type: 'hasMany',
              model: 'planet',
              inverse: 'solarSystem'
            }
          }
        }
      }
    });

    keyMap = new KeyMap();

    memory = new MemorySource({ schema, keyMap });

    remote = new JSONAPISource({ schema, keyMap, name: 'remote' });
    remote.requestProcessor.serializer.resourceKey = function() {
      return 'remoteId';
    };

    coordinator = new Coordinator({
      sources: [memory, remote]
    });

    // Query the remote server whenever the memory source is queried
    coordinator.addStrategy(
      new RequestStrategy({
        source: 'memory',
        on: 'beforeQuery',
        target: 'remote',
        action: 'pull',
        blocking: false
      })
    );

    // Update the remote server whenever the memory source is updated
    coordinator.addStrategy(
      new RequestStrategy({
        source: 'memory',
        on: 'beforeUpdate',
        target: 'remote',
        action: 'push',
        blocking: false
      })
    );

    // Sync all changes received from the remote server to the memory source
    coordinator.addStrategy(
      new SyncStrategy({
        source: 'remote',
        target: 'memory',
        blocking: true
      })
    );
  });
開發者ID:orbitjs,項目名稱:orbit.js,代碼行數:96,代碼來源:store-jsonapi-remoteid-optimistic-test.ts


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