-
Notifications
You must be signed in to change notification settings - Fork 85
/
Copy pathsdk.tsx
50 lines (43 loc) · 1.35 KB
/
sdk.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
const CommonServiceIds = {
ExtensionDataService: "ms.vss-features.extension-data-service",
GlobalMessagesService: "ms.vss-tfs-web.tfs-global-messages-service",
HostNavigationService: "ms.vss-features.host-navigation-service",
HostPageLayoutService: "ms.vss-features.host-page-layout-service",
LocationService: "ms.vss-features.location-service",
ProjectPageService: "ms.vss-tfs-web.tfs-page-data-service"
};
const mockExtensionDataManager = {
getDocuments: () => {},
getDocument: () => {}
};
const mockExtensionDataService = {
getExtensionDataManager: () => mockExtensionDataManager,
};
const mockLocationService = {
getResourceAreaLocation: () => {return 'https://hosturl'},
};
const mockProjectPageService = {
getProject: () => {
return {
id: "id",
name: "name",
};
},
};
const mockUser = {id: "userId", };
const mockExtensionContext = { id: "contextId", };
const getServiceMock = (id:string) => {
if (id == CommonServiceIds.LocationService)
return mockLocationService;
else if (id == CommonServiceIds.ProjectPageService)
return mockProjectPageService;
else
return mockExtensionDataService;
};
const mockSdk = {
getService: getServiceMock,
getUser: () => { return mockUser },
getExtensionContext: () => { return mockExtensionContext },
getAccessToken: () => { return 'token' },
};
export const MockSDK = mockSdk;