Skip to content

Commit 217cfe6

Browse files
committed
fixed test
1 parent 40a9a33 commit 217cfe6

File tree

1 file changed

+41
-22
lines changed

1 file changed

+41
-22
lines changed

src/app/devices/inline-editor/inline-editor.component.spec.ts

Lines changed: 41 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,31 +2,50 @@ import {ComponentFixture, TestBed} from '@angular/core/testing';
22

33
import {InlineEditorComponent} from './inline-editor.component';
44
import {Device} from "../../types";
5+
import {clearMocks, mockIPC, mockWindows} from "@tauri-apps/api/mocks";
56

67
describe('InlineEditorComponent', () => {
7-
let component: InlineEditorComponent;
8-
let fixture: ComponentFixture<InlineEditorComponent>;
8+
let component: InlineEditorComponent;
9+
let fixture: ComponentFixture<InlineEditorComponent>;
910

10-
beforeEach(async () => {
11-
await TestBed.configureTestingModule({
12-
imports: [InlineEditorComponent]
13-
})
14-
.compileComponents();
15-
16-
fixture = TestBed.createComponent(InlineEditorComponent);
17-
component = fixture.componentInstance;
18-
component.device = <Device>{
19-
name: 'test',
20-
host: '192.168.1.1',
21-
port: 22,
22-
username: 'root',
23-
profile: 'ose',
24-
privateKey: {openSsh: 'test'},
25-
};
26-
fixture.detectChanges();
11+
beforeEach(async () => {
12+
mockWindows("main");
13+
mockIPC((cmd, args) => {
14+
switch (cmd) {
15+
case 'plugin:device-manager|ssh_key_dir':
16+
return '/home/user/.ssh';
17+
case 'plugin:device-manager|list':
18+
return [];
19+
case 'plugin:device-manager|app_ssh_pubkey':
20+
return 'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC3...';
21+
}
22+
throw new Error(`Unknown command: ${cmd}`);
2723
});
24+
(window as any)['__TAURI_INTERNALS__'].plugins = {
25+
path: {sep: '/'},
26+
}
27+
await TestBed.configureTestingModule({
28+
imports: [InlineEditorComponent]
29+
}).compileComponents();
2830

29-
it('should create', () => {
30-
expect(component).toBeTruthy();
31-
});
31+
fixture = TestBed.createComponent(InlineEditorComponent);
32+
component = fixture.componentInstance;
33+
component.device = <Device>{
34+
name: 'test',
35+
host: '192.168.1.1',
36+
port: 22,
37+
username: 'root',
38+
profile: 'ose',
39+
privateKey: {openSsh: 'test'},
40+
};
41+
fixture.detectChanges();
42+
});
43+
44+
afterEach(() => {
45+
clearMocks();
46+
});
47+
48+
it('should create', () => {
49+
expect(component).toBeTruthy();
50+
});
3251
});

0 commit comments

Comments
 (0)