本文整理匯總了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
})
);
});