-
Notifications
You must be signed in to change notification settings - Fork 362
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- remove rollbar service - ErrorService now passed in as a startOption, configuration passed to init function called on the service.
- Loading branch information
Showing
7 changed files
with
74 additions
and
150 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 0 additions & 39 deletions
39
lib/Models/ErrorServiceProviders/RollbarErrorServiceProvider.ts
This file was deleted.
Oops, something went wrong.
44 changes: 0 additions & 44 deletions
44
lib/Models/ErrorServiceProviders/SentryErrorServiceProvider.ts
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,60 @@ | ||
import { initializeErrorServiceProvider } from "../../lib/Models/ErrorServiceProviders/ErrorService"; | ||
import RollbarErrorServiceProvider from "../../lib/Models/ErrorServiceProviders/RollbarErrorServiceProvider"; | ||
import TerriaError from "../../lib/Core/TerriaError"; | ||
import { ErrorServiceProvider } from "../../lib/Models/ErrorServiceProviders/ErrorService"; | ||
import StubErrorServiceProvider from "../../lib/Models/ErrorServiceProviders/StubErrorServiceProvider"; | ||
import Terria from "../../lib/Models/Terria"; | ||
|
||
describe("initializeErrorServiceProvider", function () { | ||
it("can initialize RollbarErrorServiceProvider", async function () { | ||
const errorService = await initializeErrorServiceProvider({ | ||
provider: "rollbar", | ||
configuration: {} | ||
describe("ErrorService", function () { | ||
let mockErrorServiceProvider: ErrorServiceProvider; | ||
let terria: Terria; | ||
|
||
beforeAll(() => { | ||
jasmine.Ajax.install(); | ||
jasmine.Ajax.stubRequest(/.*/).andError({}); | ||
jasmine.Ajax.stubRequest(/.*(serverconfig|proxyabledomains).*/).andReturn({ | ||
responseText: JSON.stringify({ foo: "bar" }) | ||
}); | ||
jasmine.Ajax.stubRequest("test-config.json").andReturn({ | ||
responseText: JSON.stringify({ config: true }) | ||
}); | ||
expect(errorService instanceof RollbarErrorServiceProvider).toBe(true); | ||
mockErrorServiceProvider = { | ||
init: () => {}, | ||
error: () => {} | ||
}; | ||
}); | ||
|
||
it("throws an error when an invalid provider type is given", async function () { | ||
let error; | ||
try { | ||
await initializeErrorServiceProvider({ | ||
provider: "foo", | ||
configuration: undefined | ||
}); | ||
} catch (e: any) { | ||
error = e; | ||
} | ||
expect(error.message).toBe(`Unknown error service provider: foo`); | ||
beforeEach(() => { | ||
terria = new Terria({ | ||
appBaseHref: "/", | ||
baseUrl: "./" | ||
}); | ||
}); | ||
|
||
it("Initializes an error service, passing in config", async function () { | ||
const initSpy = spyOn(mockErrorServiceProvider, "init"); | ||
await terria.start({ | ||
configUrl: "test-config.json", | ||
errorService: mockErrorServiceProvider | ||
}); | ||
expect(initSpy).toHaveBeenCalledTimes(1); | ||
}); | ||
|
||
it("Gets called with error", async function () { | ||
const errorSpy = spyOn(mockErrorServiceProvider, "error").and.callThrough(); | ||
await terria.start({ | ||
configUrl: "test-config.json", | ||
errorService: mockErrorServiceProvider | ||
}); | ||
const error = new TerriaError({ | ||
message: "test error" | ||
}); | ||
terria.raiseErrorToUser(error); | ||
expect(errorSpy).toHaveBeenCalledWith(error); | ||
}); | ||
|
||
it("Falls back to stub provider", () => { | ||
terria.start({ | ||
configUrl: "test-config.json" | ||
}); | ||
expect(terria.errorService).toEqual(jasmine.any(StubErrorServiceProvider)); | ||
}); | ||
}); |