Skip to content

Commit 2b0c098

Browse files
authored
Merge pull request #342 from microsoftgraph/copilot/fix-341
fix: Beta SDK default base URL to use beta endpoint instead of v1.0
2 parents 568981f + 6839ff4 commit 2b0c098

File tree

2 files changed

+43
-1
lines changed

2 files changed

+43
-1
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import { describe, it } from 'mocha';
2+
import { expect } from 'chai';
3+
import { createGraphBetaServiceClient } from '@microsoft/msgraph-beta-sdk';
4+
5+
// Simple mock request adapter for testing
6+
class MockRequestAdapter {
7+
public baseUrl: string | undefined = undefined;
8+
9+
constructor(baseUrl?: string) {
10+
this.baseUrl = baseUrl;
11+
}
12+
}
13+
14+
describe("GraphBetaServiceClient Base URL Tests", () => {
15+
it("should set default base URL to beta endpoint when undefined", () => {
16+
const mockAdapter = new MockRequestAdapter();
17+
18+
// Call the function which should set the default base URL
19+
createGraphBetaServiceClient(mockAdapter as any);
20+
21+
expect(mockAdapter.baseUrl).to.equal("https://graph.microsoft.com/beta");
22+
});
23+
24+
it("should set default base URL to beta endpoint when empty string", () => {
25+
const mockAdapter = new MockRequestAdapter("");
26+
27+
// Call the function which should set the default base URL
28+
createGraphBetaServiceClient(mockAdapter as any);
29+
30+
expect(mockAdapter.baseUrl).to.equal("https://graph.microsoft.com/beta");
31+
});
32+
33+
it("should not override existing base URL", () => {
34+
const customUrl = "https://custom.graph.endpoint.com/beta";
35+
const mockAdapter = new MockRequestAdapter(customUrl);
36+
37+
// Call the function which should NOT override the existing URL
38+
createGraphBetaServiceClient(mockAdapter as any);
39+
40+
expect(mockAdapter.baseUrl).to.equal(customUrl);
41+
});
42+
});

packages/msgraph-beta-sdk/graphBetaServiceClient.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export interface GraphBetaServiceClient extends BaseRequestBuilder<GraphBetaServ
1313
*/
1414
export function createGraphBetaServiceClient(requestAdapter: RequestAdapter) {
1515
if (requestAdapter.baseUrl === undefined || requestAdapter.baseUrl === "") {
16-
requestAdapter.baseUrl = "https://graph.microsoft.com/v1.0";
16+
requestAdapter.baseUrl = "https://graph.microsoft.com/beta";
1717
}
1818
const pathParameters: Record<string, unknown> = {
1919
"baseurl": requestAdapter.baseUrl,

0 commit comments

Comments
 (0)