当前位置: 首页>>代码示例>>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;未经允许,请勿转载。