Skip to content

Commit

Permalink
Rename to 'updateBaseUrl()'.
Browse files Browse the repository at this point in the history
  • Loading branch information
elle-j committed Mar 4, 2024
1 parent 8ce9c3c commit 8bc880d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions integration-tests/tests/src/tests/experimental/base-url.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ import { App } from "realm";
import "realm/experimental/base-url";

describe("Experimental", () => {
it("switches base URL", async function (this: Mocha.Context) {
it("updates base URL", function (this: Mocha.Context) {
const app = new App("12345");
expect(app.baseUrl).equals("https://realm.mongodb.com");

// @ts-expect-error Assigning to read-only property.
expect(() => (app.baseUrl = "new URL")).to.throw("Cannot assign the base URL, please use `switchBaseUrl()`");
expect(() => (app.baseUrl = "new URL")).to.throw("Cannot assign the base URL, please use `updateBaseUrl()`");
expect(app.baseUrl).equals("https://realm.mongodb.com");

// Switching to a URL that will not work.
expect(app.switchBaseUrl("https://example")).to.be.rejectedWith("Error: request to https://example/");
// Update to a URL that will not work.
expect(app.updateBaseUrl("https://example")).to.be.rejectedWith("Error: request to https://example/");
});
});
8 changes: 4 additions & 4 deletions packages/realm/src/experimental/base-url.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ declare module "../app-services/App" {
get baseUrl(): string;

/**
* Switch the base URL.
* Update the base URL.
* @experimental This feature is experimental and may be changed or removed.
*/
switchBaseUrl(url: string): Promise<void>;
updateBaseUrl(url: string): Promise<void>;
}
}

Expand All @@ -39,10 +39,10 @@ Object.defineProperty(App.prototype, "baseUrl", {
return this.internal.getBaseUrl();
},
set() {
throw new Error("Cannot assign the base URL, please use `switchBaseUrl()`.");
throw new Error("Cannot assign the base URL, please use `updateBaseUrl()`.");
},
});

App.prototype.switchBaseUrl = async function (this: App, url: string) {
App.prototype.updateBaseUrl = async function (this: App, url: string) {
await this.internal.updateBaseUrl(url);
};

0 comments on commit 8bc880d

Please sign in to comment.