Skip to content

Commit

Permalink
Fixed broken tests
Browse files Browse the repository at this point in the history
  • Loading branch information
oliverschwendener committed Mar 7, 2019
1 parent 233f04a commit 7020bf8
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 5 deletions.
4 changes: 4 additions & 0 deletions src/common/logger/log-message-type.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export enum LogMessageType {
Error,
Debug,
}
6 changes: 6 additions & 0 deletions src/common/logger/log-message.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { LogMessageType } from "./log-message-type";

export interface LogMessage {
message: string;
type: LogMessageType;
}
12 changes: 7 additions & 5 deletions src/tests/search-engine.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ import { FakeSearchPlugin } from "./fake-search-plugin";
import { SearchResultItem } from "../common/search-result-item";
import { PluginType } from "../main/plugin-type";
import { dummyIcon } from "./dummy-icon";
import { TestLogger } from "./test-logger";

describe(SearchEngine.name, () => {
const logger = new TestLogger();
it("should find search results when searching for the exact name", (done) => {
const items: SearchResultItem[] = [
{
Expand All @@ -30,7 +32,7 @@ describe(SearchEngine.name, () => {
} as UserConfigOptions;
const config = Object.assign({}, defaultUserConfigOptions, userConfig);

const searchEngine = new SearchEngine(searchPlugins, [], [], config, englishTranslationSet);
const searchEngine = new SearchEngine(searchPlugins, [], [], config, englishTranslationSet, logger);

searchEngine.getSearchResults("Google Chrome")
.then((searchResults) => {
Expand Down Expand Up @@ -63,7 +65,7 @@ describe(SearchEngine.name, () => {
} as UserConfigOptions;
const config = Object.assign({}, defaultUserConfigOptions, userConfig);

const searchEngine = new SearchEngine(searchPlugins, [], [], config, translationSet);
const searchEngine = new SearchEngine(searchPlugins, [], [], config, translationSet, logger);

searchEngine.getSearchResults("blabla")
.then((searchResults) => {
Expand Down Expand Up @@ -96,7 +98,7 @@ describe(SearchEngine.name, () => {
} as UserConfigOptions;
const config = Object.assign({}, defaultUserConfigOptions, userConfig);

const searchEngine = new SearchEngine(searchPlugins, [], [], config, translationSet);
const searchEngine = new SearchEngine(searchPlugins, [], [], config, translationSet, logger);

searchEngine.getSearchResults("gOoGlE ChRoMe")
.then((searchResults) => {
Expand Down Expand Up @@ -131,7 +133,7 @@ describe(SearchEngine.name, () => {
} as UserConfigOptions;
const config = Object.assign({}, defaultUserConfigOptions, userConfig);

const searchEngine = new SearchEngine(searchPlugins, [], [], config, translationSet);
const searchEngine = new SearchEngine(searchPlugins, [], [], config, translationSet, logger);

searchEngine.getSearchResults("gglchrm")
.then((searchResults) => {
Expand Down Expand Up @@ -166,7 +168,7 @@ describe(SearchEngine.name, () => {
} as UserConfigOptions;
const config = Object.assign({}, defaultUserConfigOptions, userConfig);

const searchEngine = new SearchEngine(searchPlugins, [], [], config, translationSet);
const searchEngine = new SearchEngine(searchPlugins, [], [], config, translationSet, logger);

searchEngine.getSearchResults("gglchrm")
.then((searchResults) => {
Expand Down
29 changes: 29 additions & 0 deletions src/tests/test-logger.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { Logger } from "../common/logger/logger";
import { LogMessage } from "../common/logger/log-message";
import { LogMessageType } from "../common/logger/log-message-type";

export class TestLogger implements Logger {
private readonly messages: LogMessage[];

constructor() {
this.messages = [];
}

public debug(message: string) {
this.messages.push({
message,
type: LogMessageType.Error,
});
}

public error(message: string) {
this.messages.push({
message,
type: LogMessageType.Debug,
});
}

public getAllMessages(): LogMessage[] {
return this.messages;
}
}

0 comments on commit 7020bf8

Please sign in to comment.