本文整理汇总了TypeScript中vs/workbench/parts/experiments/test/electron-browser/experimentService.test.TestExperimentService类的典型用法代码示例。如果您正苦于以下问题:TypeScript test.TestExperimentService类的具体用法?TypeScript test.TestExperimentService怎么用?TypeScript test.TestExperimentService使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了test.TestExperimentService类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: suite
suite('Experimental Prompts', () => {
let instantiationService: TestInstantiationService;
let experimentService: TestExperimentService;
let experimentalPrompt: ExperimentalPrompts;
let onExperimentEnabledEvent: Emitter<IExperiment>;
let storageData = {};
const promptText = 'Hello there! Can you see this?';
const experiment: IExperiment =
{
id: 'experiment1',
enabled: true,
state: ExperimentState.Run,
action: {
type: ExperimentActionType.Prompt,
properties: {
promptText,
commands: [
{
text: 'Yes',
externalLink: 'https://code.visualstudio.com'
},
{
text: 'No'
}
]
}
}
};
suiteSetup(() => {
instantiationService = new TestInstantiationService();
instantiationService.stub(ILifecycleService, new TestLifecycleService());
instantiationService.stub(ITelemetryService, NullTelemetryService);
onExperimentEnabledEvent = new Emitter<IExperiment>();
});
setup(() => {
storageData = {};
instantiationService.stub(IStorageService, {
get: (a, b, c) => a === 'experiments.experiment1' ? JSON.stringify(storageData) : c,
store: (a, b, c) => {
if (a === 'experiments.experiment1') {
storageData = JSON.parse(b);
}
}
});
instantiationService.stub(INotificationService, new TestNotificationService());
experimentService = instantiationService.createInstance(TestExperimentService);
experimentService.onExperimentEnabled = onExperimentEnabledEvent.event;
instantiationService.stub(IExperimentService, experimentService);
});
teardown(() => {
if (experimentService) {
experimentService.dispose();
}
if (experimentalPrompt) {
experimentalPrompt.dispose();
}
});
test('Show experimental prompt if experiment should be run. Choosing option with link should mark experiment as complete', () => {
storageData = {
enabled: true,
state: ExperimentState.Run
};
instantiationService.stub(INotificationService, {
prompt: (a: Severity, b: string, c: IPromptChoice[], options) => {
assert.equal(b, promptText);
assert.equal(c.length, 2);
c[0].run();
}
});
experimentalPrompt = instantiationService.createInstance(ExperimentalPrompts);
onExperimentEnabledEvent.fire(experiment);
return TPromise.as(null).then(result => {
assert.equal(storageData['state'], ExperimentState.Complete);
});
});
test('Show experimental prompt if experiment should be run. Choosing negative option should mark experiment as complete', () => {
storageData = {
enabled: true,
state: ExperimentState.Run
};
instantiationService.stub(INotificationService, {
prompt: (a: Severity, b: string, c: IPromptChoice[], options) => {
assert.equal(b, promptText);
//.........这里部分代码省略.........
示例2: suite
suite('Experimental Prompts', () => {
let instantiationService: TestInstantiationService;
let experimentService: TestExperimentService;
let experimentalPrompt: ExperimentalPrompts;
let onExperimentEnabledEvent: Emitter<IExperiment>;
let storageData = {};
const promptText = 'Hello there! Can you see this?';
const experiment: IExperiment =
{
id: 'experiment1',
enabled: true,
state: ExperimentState.Run,
action: {
type: ExperimentActionType.Prompt,
properties: {
promptText,
commands: [
{
text: 'Yes',
externalLink: 'https://code.visualstudio.com'
},
{
text: 'No'
}
]
}
}
};
suiteSetup(() => {
instantiationService = new TestInstantiationService();
instantiationService.stub(ILifecycleService, new TestLifecycleService());
instantiationService.stub(ITelemetryService, NullTelemetryService);
onExperimentEnabledEvent = new Emitter<IExperiment>();
});
setup(() => {
storageData = {};
instantiationService.stub(IStorageService, {
get: (a, b, c) => a === 'experiments.experiment1' ? JSON.stringify(storageData) : c,
store: (a, b, c) => {
if (a === 'experiments.experiment1') {
storageData = JSON.parse(b);
}
}
});
instantiationService.stub(INotificationService, new TestNotificationService());
experimentService = instantiationService.createInstance(TestExperimentService);
experimentService.onExperimentEnabled = onExperimentEnabledEvent.event;
instantiationService.stub(IExperimentService, experimentService);
});
teardown(() => {
if (experimentService) {
experimentService.dispose();
}
if (experimentalPrompt) {
experimentalPrompt.dispose();
}
});
test('Show experimental prompt if experiment should be run. Choosing option with link should mark experiment as complete', () => {
storageData = {
enabled: true,
state: ExperimentState.Run
};
instantiationService.stub(INotificationService, {
prompt: (a: Severity, b: string, c: IPromptChoice[], options) => {
assert.equal(b, promptText);
assert.equal(c.length, 2);
c[0].run();
}
});
experimentalPrompt = instantiationService.createInstance(ExperimentalPrompts);
onExperimentEnabledEvent.fire(experiment);
return TPromise.as(null).then(result => {
assert.equal(storageData['state'], ExperimentState.Complete);
});
});
test('Show experimental prompt if experiment should be run. Choosing negative option should mark experiment as complete', () => {
storageData = {
enabled: true,
state: ExperimentState.Run
};
instantiationService.stub(INotificationService, {
prompt: (a: Severity, b: string, c: IPromptChoice[], options) => {
assert.equal(b, promptText);
//.........这里部分代码省略.........
示例3:
teardown(() => {
if (experimentService) {
experimentService.dispose();
}
if (experimentalPrompt) {
experimentalPrompt.dispose();
}
});