-
-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy paths3.component.spec.ts
More file actions
57 lines (49 loc) · 1.64 KB
/
Copy paths3.component.spec.ts
File metadata and controls
57 lines (49 loc) · 1.64 KB
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
51
52
53
54
55
56
57
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { ConnectionsService } from 'src/app/services/connections.service';
import { S3Service } from 'src/app/services/s3.service';
import { TablesService } from 'src/app/services/tables.service';
import { vi } from 'vitest';
import { S3DisplayComponent } from './s3.component';
describe('S3DisplayComponent', () => {
let component: S3DisplayComponent;
let fixture: ComponentFixture<S3DisplayComponent>;
const mockS3Service: Partial<S3Service> = {
getFileUrl: vi.fn(),
};
const mockConnectionsService: Partial<ConnectionsService> = {
currentConnectionID: 'test-conn',
};
const mockTablesService: Partial<TablesService> = {
currentTableName: 'test-table',
};
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [S3DisplayComponent],
providers: [
{ provide: S3Service, useValue: mockS3Service },
{ provide: ConnectionsService, useValue: mockConnectionsService },
{ provide: TablesService, useValue: mockTablesService },
],
}).compileComponents();
});
beforeEach(() => {
fixture = TestBed.createComponent(S3DisplayComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
it('should detect image type from widget params', () => {
fixture.componentRef.setInput('widgetStructure', {
widget_params: {
bucket: 'my-bucket',
access_key_id: 'COMPANY-SECRET/bucket-access-key-id',
access_key: 'COMPANY-SECRET/bucket-access-key',
type: 'image',
},
});
component.ngOnInit();
expect(component.isImageType).toBe(true);
});
});