Clean up the tests
This commit is contained in:
Родитель
39ceb4f4fa
Коммит
9a0e854bc4
|
@ -6,7 +6,6 @@
|
|||
import { WarningMessageObserver } from '../../../src/observers/WarningMessageObserver';
|
||||
import { assert, use as chaiUse, expect, should } from 'chai';
|
||||
import { getFakeVsCode, getMSBuildDiagnosticsMessage, getOmnisharpMSBuildProjectDiagnosticsEvent, getOmnisharpServerOnErrorEvent } from '../testAssets/Fakes';
|
||||
import { BaseEvent } from '../../../src/omnisharp/loggingEvents';
|
||||
import { vscode } from '../../../src/vscodeAdapter';
|
||||
import { TestScheduler } from 'rxjs/testing/TestScheduler';
|
||||
import { Observable } from 'rxjs/Observable';
|
||||
|
@ -73,7 +72,12 @@ suite('WarningMessageObserver', () => {
|
|||
let event = getOmnisharpMSBuildProjectDiagnosticsEvent("someFile",
|
||||
[getMSBuildDiagnosticsMessage("warningFile", "", "", 0, 0, 0, 0)],
|
||||
[]);
|
||||
observer.post(event);
|
||||
let marble = `a`;
|
||||
let marble_event_map = { a: event };
|
||||
let eventList = scheduler.createHotObservable(marble, marble_event_map);
|
||||
eventList.subscribe(e => observer.post(e));
|
||||
scheduler.flush();
|
||||
expect(warningMessages).to.be.empty;
|
||||
expect(invokedCommand).to.be.undefined;
|
||||
});
|
||||
|
||||
|
@ -82,88 +86,95 @@ suite('WarningMessageObserver', () => {
|
|||
let event = getOmnisharpMSBuildProjectDiagnosticsEvent("someFile",
|
||||
[getMSBuildDiagnosticsMessage("warningFile", "", "", 0, 0, 0, 0)],
|
||||
[getMSBuildDiagnosticsMessage("warningFile", "", "", 0, 0, 0, 0)]);
|
||||
newObserver.post(event);
|
||||
let marble = `a`;
|
||||
let marble_event_map = { a: event };
|
||||
let eventList = scheduler.createHotObservable(marble, marble_event_map);
|
||||
eventList.subscribe(e => newObserver.post(e));
|
||||
scheduler.flush();
|
||||
expect(warningMessages).to.be.empty;
|
||||
expect(invokedCommand).to.be.undefined;
|
||||
});
|
||||
|
||||
[
|
||||
getOmnisharpMSBuildProjectDiagnosticsEvent("someFile",
|
||||
[getMSBuildDiagnosticsMessage("warningFile", "", "", 1, 2, 3, 4)],
|
||||
[getMSBuildDiagnosticsMessage("errorFile", "", "", 5, 6, 7, 8)]),
|
||||
getOmnisharpServerOnErrorEvent("someText", "someFile", 1, 2)
|
||||
].forEach((event: BaseEvent) => {
|
||||
suite(`${event.constructor.name}`, () => {
|
||||
{
|
||||
eventA: getOmnisharpMSBuildProjectDiagnosticsEvent("someFile",
|
||||
[getMSBuildDiagnosticsMessage("warningFile", "", "", 1, 2, 3, 4)],
|
||||
[getMSBuildDiagnosticsMessage("errorFile", "", "", 5, 6, 7, 8)]),
|
||||
|
||||
eventB: getOmnisharpMSBuildProjectDiagnosticsEvent("BFile",
|
||||
[getMSBuildDiagnosticsMessage("warningFile", "", "", 1, 2, 3, 4)],
|
||||
[getMSBuildDiagnosticsMessage("errorFile", "", "", 5, 6, 7, 8)]),
|
||||
|
||||
eventC: getOmnisharpMSBuildProjectDiagnosticsEvent("CFile",
|
||||
[getMSBuildDiagnosticsMessage("warningFile", "", "", 1, 2, 3, 4)],
|
||||
[getMSBuildDiagnosticsMessage("errorFile", "", "", 5, 6, 7, 8)]),
|
||||
assertion1: '[1] Some projects have trouble loading. Please review the output for more details.',
|
||||
assertion2: '[2] Some projects have trouble loading. Please review the output for more details.',
|
||||
expected: "Some projects have trouble loading. Please review the output for more details.",
|
||||
command: "o.showOutput"
|
||||
},
|
||||
{
|
||||
eventA: getOmnisharpServerOnErrorEvent("someText1", "someFile1", 1, 2),
|
||||
eventB: getOmnisharpServerOnErrorEvent("someText2", "someFile2", 1, 2),
|
||||
eventC: getOmnisharpServerOnErrorEvent("someText3", "someFile3", 1, 2),
|
||||
assertion1: '[1] Some projects have trouble loading. Please review the output for more details.',
|
||||
assertion2: '[2] Some projects have trouble loading. Please review the output for more details.',
|
||||
expected: "Some projects have trouble loading. Please review the output for more details.",
|
||||
command: "o.showOutput"
|
||||
}
|
||||
].forEach(elem => {
|
||||
suite(`${elem.eventA.constructor.name}`, () => {
|
||||
test(`When the event is fired then a warning message is displayed`, () => {
|
||||
let marble = `${timeToMarble(1500)}a`;
|
||||
let marble_event_map = { a: event };
|
||||
let marble_event_map = { a: elem.eventA };
|
||||
let eventList = scheduler.createHotObservable(marble, marble_event_map);
|
||||
eventList.subscribe(e => observer.post(e));
|
||||
scheduler.expectObservable(assertionObservable).toBe(`${timeToMarble(3000)}a`, { a: '[1] Some projects have trouble loading. Please review the output for more details.' });
|
||||
scheduler.expectObservable(assertionObservable).toBe(`${timeToMarble(3000)}a`, { a: elem.assertion1 });
|
||||
scheduler.flush();
|
||||
|
||||
expect(warningMessages.length).to.be.equal(1);
|
||||
expect(warningMessages[0]).to.be.equal("Some projects have trouble loading. Please review the output for more details.");
|
||||
expect(warningMessages[0]).to.be.equal(elem.expected);
|
||||
});
|
||||
|
||||
test(`When events are fired rapidly, then they are debounced by 1500 ms`, () => {
|
||||
let marble = `${timeToMarble(1000)}a${timeToMarble(500)}b${timeToMarble(500)}c`;
|
||||
|
||||
let eventB = getOmnisharpMSBuildProjectDiagnosticsEvent("BFile",
|
||||
[getMSBuildDiagnosticsMessage("warningFile", "", "", 1, 2, 3, 4)],
|
||||
[getMSBuildDiagnosticsMessage("errorFile", "", "", 5, 6, 7, 8)]);
|
||||
|
||||
let eventC = getOmnisharpMSBuildProjectDiagnosticsEvent("CFile",
|
||||
[getMSBuildDiagnosticsMessage("warningFile", "", "", 1, 2, 3, 4)],
|
||||
[getMSBuildDiagnosticsMessage("errorFile", "", "", 5, 6, 7, 8)]);
|
||||
|
||||
let marble_event_map = { a: event, b: eventB, c: eventC };
|
||||
let marble_event_map = { a: elem.eventA, b: elem.eventB, c: elem.eventC };
|
||||
let eventList = scheduler.createHotObservable(marble, marble_event_map);
|
||||
eventList.subscribe(e => observer.post(e));
|
||||
scheduler.expectObservable(assertionObservable).toBe(`${timeToMarble(3520)}a`, { a: '[1] Some projects have trouble loading. Please review the output for more details.' });
|
||||
scheduler.expectObservable(assertionObservable).toBe(`${timeToMarble(3520)}a`, { a: elem.assertion1 });
|
||||
scheduler.flush();
|
||||
|
||||
expect(warningMessages.length).to.be.equal(1);
|
||||
expect(warningMessages[0]).to.be.equal("Some projects have trouble loading. Please review the output for more details.");
|
||||
expect(warningMessages[0]).to.be.equal(elem.expected);
|
||||
});
|
||||
|
||||
test(`When events are 1500 ms apart, then they are not debounced`, () => {
|
||||
let marble = `${timeToMarble(1000)}a${timeToMarble(490)}b${timeToMarble(1500)}c`;
|
||||
|
||||
let eventB = getOmnisharpMSBuildProjectDiagnosticsEvent("BFile",
|
||||
[getMSBuildDiagnosticsMessage("warningFile", "", "", 1, 2, 3, 4)],
|
||||
[getMSBuildDiagnosticsMessage("errorFile", "", "", 5, 6, 7, 8)]);
|
||||
|
||||
let eventC = getOmnisharpMSBuildProjectDiagnosticsEvent("CFile",
|
||||
[getMSBuildDiagnosticsMessage("warningFile", "", "", 1, 2, 3, 4)],
|
||||
[getMSBuildDiagnosticsMessage("errorFile", "", "", 5, 6, 7, 8)]);
|
||||
|
||||
let marble_event_map = { a: event, b: eventB, c: eventC };
|
||||
let marble_event_map = { a: elem.eventA, b: elem.eventB, c: elem.eventC };
|
||||
let eventList = scheduler.createHotObservable(marble, marble_event_map);
|
||||
eventList.subscribe(e => observer.post(e));
|
||||
scheduler.expectObservable(assertionObservable).toBe(`${timeToMarble(3000)}a${timeToMarble(1500)}b`,
|
||||
{
|
||||
a: '[1] Some projects have trouble loading. Please review the output for more details.',
|
||||
b: '[2] Some projects have trouble loading. Please review the output for more details.'
|
||||
a: elem.assertion1,
|
||||
b: elem.assertion2
|
||||
});
|
||||
scheduler.flush();
|
||||
expect(warningMessages.length).to.be.equal(2);
|
||||
expect(warningMessages[0]).to.be.equal("Some projects have trouble loading. Please review the output for more details.");
|
||||
expect(warningMessages[0]).to.be.equal(elem.expected);
|
||||
});
|
||||
|
||||
test(`Given a warning message, when the user clicks ok the command is executed`, async () => {
|
||||
let marble = `${timeToMarble(1500)}a`;
|
||||
let eventList = scheduler.createHotObservable(marble, { a: event });
|
||||
let eventList = scheduler.createHotObservable(marble, { a: elem.eventA });
|
||||
scheduler.expectObservable(eventList.map(e => observer.post(e)));
|
||||
scheduler.flush();
|
||||
doClickOk();
|
||||
await commandDone;
|
||||
expect(invokedCommand).to.be.equal("o.showOutput");
|
||||
expect(invokedCommand).to.be.equal(elem.command);
|
||||
});
|
||||
|
||||
test(`Given a warning message, when the user clicks cancel the command is not executed`, async () => {
|
||||
let marble = `${timeToMarble(1500)}a--|`;
|
||||
let eventList = scheduler.createHotObservable(marble, { a: event });
|
||||
let eventList = scheduler.createHotObservable(marble, { a: elem.eventA });
|
||||
scheduler.expectObservable(eventList.map(e => observer.post(e)));
|
||||
scheduler.flush();
|
||||
doClickCancel();
|
||||
|
|
Загрузка…
Ссылка в новой задаче