Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
escaton committed Apr 13, 2019
1 parent 01b63cb commit af884bb
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions tests/extension.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ const extensionManager = {
register: jest.fn(),
getByName: jest.fn().mockReturnValue(jestInstance),
get: jest.fn().mockReturnValue(jestInstance),
registerAll: jest.fn(),
unregisterAll: jest.fn(),
registerCommand: jest.fn().mockImplementation((...args) => args),
}
Expand All @@ -78,6 +79,10 @@ describe('Extension', () => {

beforeEach(() => {
context.subscriptions.push.mockReset()
jestInstance.startProcess.mockReset()
jestInstance.stopProcess.mockReset()
extensionManager.registerAll.mockReset()
extensionManager.unregisterAll.mockReset()
})

it('should instantiate ExtensionManager', () => {
Expand Down Expand Up @@ -141,6 +146,49 @@ describe('Extension', () => {
expect(jestInstance.stopProcess).toHaveBeenCalled()
})

it('should register a command to restart extension', () => {
activate(context)
const callArg = context.subscriptions.push.mock.calls[0].find(args => {
return args[0] === `${extensionName}.restart`
})

expect(callArg).toBeDefined()
callArg[1](jestInstance)
expect(jestInstance.startProcess).toHaveBeenCalled()
expect(jestInstance.stopProcess).toHaveBeenCalled()
})

it('should register a command to start-all extensions', () => {
activate(context)
const callArg = context.subscriptions.push.mock.calls[0].find(args => {
return args[0] === `${extensionName}.start-all`
})
expect(callArg).toBeDefined()
callArg[1](jestInstance)
expect(extensionManager.registerAll).toHaveBeenCalled()
})

it('should register a command to stop-all extensions', () => {
activate(context)
const callArg = context.subscriptions.push.mock.calls[0].find(args => {
return args[0] === `${extensionName}.stop-all`
})
expect(callArg).toBeDefined()
callArg[1](jestInstance)
expect(extensionManager.unregisterAll).toHaveBeenCalled()
})

it('should register a command to restart-all extensions', () => {
activate(context)
const callArg = context.subscriptions.push.mock.calls[0].find(args => {
return args[0] === `${extensionName}.restart-all`
})
expect(callArg).toBeDefined()
callArg[1](jestInstance)
expect(extensionManager.registerAll).toHaveBeenCalled()
expect(extensionManager.unregisterAll).toHaveBeenCalled()
})

it('should register a command to toggle the coverage overlay visibility', () => {
activate(context)
const callArg = context.subscriptions.push.mock.calls[0].find(args => {
Expand Down

0 comments on commit af884bb

Please sign in to comment.