Fixed Karma spec
This commit is contained in:
parent
9904c12746
commit
136baeda50
2 changed files with 13 additions and 4 deletions
|
@ -66,7 +66,7 @@
|
|||
},
|
||||
beforeDestroy() {
|
||||
eventHub.$off('enable.key', this.enableKey);
|
||||
eventHub.$off('remove.key', this.removeKey);
|
||||
eventHub.$off('remove.key', this.disableKey);
|
||||
eventHub.$off('disable.key', this.disableKey);
|
||||
},
|
||||
};
|
||||
|
|
|
@ -116,15 +116,24 @@ describe('Deploy keys app component', () => {
|
|||
expect(vm.service.disableKey).toHaveBeenCalledWith(key.id);
|
||||
});
|
||||
|
||||
it('calls disableKey when removing a key', () => {
|
||||
it('calls disableKey when removing a key', (done) => {
|
||||
const key = data.public_keys[0];
|
||||
|
||||
spyOn(window, 'confirm').and.returnValue(true);
|
||||
spyOn(vm, 'disableKey');
|
||||
spyOn(vm.service, 'getKeys');
|
||||
spyOn(vm.service, 'disableKey').and.callFake(() => new Promise((resolve) => {
|
||||
resolve();
|
||||
|
||||
setTimeout(() => {
|
||||
expect(vm.service.getKeys).toHaveBeenCalled();
|
||||
|
||||
done();
|
||||
});
|
||||
}));
|
||||
|
||||
eventHub.$emit('remove.key', key);
|
||||
|
||||
expect(vm.disableKey).toHaveBeenCalledWith(key);
|
||||
expect(vm.service.disableKey).toHaveBeenCalledWith(key.id);
|
||||
});
|
||||
|
||||
it('hasKeys returns true when there are keys', () => {
|
||||
|
|
Loading…
Reference in a new issue