Skip to content

Commit

Permalink
fix: add additional tests
Browse files Browse the repository at this point in the history
@W-15295136@
  • Loading branch information
peternhale committed Mar 26, 2024
1 parent a0e5cfd commit dfa3f5f
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,4 @@ jspm_packages/

# parcel-bundler cache (https://parceljs.org/)
.cache
/.idea
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@salesforce/vscode-service-provider",
"version": "0.0.1",
"version": "0.0.1-aplha.0",
"description": "Library that provides access to Salesforce VSCode Service Provider",
"main": "index.js",
"author": "Peter Hale <[email protected]>",
Expand Down
30 changes: 30 additions & 0 deletions test/services/serviceProvider.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,34 @@ describe('ServiceProvider', () => {
const hasInstance = ServiceProvider.has(ServiceType.Logger, 'instance1');
expect(hasInstance).toBe(true);
});
it('should remove a service instance', async () => {
(vscode.commands.executeCommand as jest.Mock).mockResolvedValue(
'mockService'
);
await ServiceProvider.getService(ServiceType.Logger, 'instance1');
ServiceProvider.remove(ServiceType.Logger, 'instance1');
const hasInstance = ServiceProvider.has(ServiceType.Logger, 'instance1');
expect(hasInstance).toBe(false);
});

it('should remove a service', async () => {
(vscode.commands.executeCommand as jest.Mock).mockResolvedValue(
'mockService'
);
await ServiceProvider.getService(ServiceType.Logger, 'instance1');
ServiceProvider.removeService(ServiceType.Logger);
const hasService = ServiceProvider.hasService(ServiceType.Logger);
expect(hasService).toBe(false);
});

it('should clear all services', async () => {
(vscode.commands.executeCommand as jest.Mock).mockResolvedValue(
'mockService'
);
await ServiceProvider.getService(ServiceType.Logger, 'instance1');
await ServiceProvider.getService(ServiceType.Logger, 'instance2');
ServiceProvider.clearAllServices();
const hasService = ServiceProvider.hasService(ServiceType.Logger);
expect(hasService).toBe(false);
});
});

0 comments on commit dfa3f5f

Please sign in to comment.