本文整理汇总了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';
};
});
示例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
})
);
});