feat: chains form
This commit is contained in:
49
src/app/pages/settings/chains/chain-form/chain-form.spec.ts
Normal file
49
src/app/pages/settings/chains/chain-form/chain-form.spec.ts
Normal file
@@ -0,0 +1,49 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { ChainForm } from './chain-form';
|
||||
import { provideTranslateService } from '@ngx-translate/core';
|
||||
import { Component } from '@angular/core';
|
||||
import { ImageUploader } from '../../../../components/image-uploader/image-uploader';
|
||||
import { By } from '@angular/platform-browser';
|
||||
|
||||
@Component({
|
||||
template: ``
|
||||
})
|
||||
class ImageUploaderMock extends ImageUploader {
|
||||
|
||||
}
|
||||
|
||||
describe('ChainForm', () => {
|
||||
let component: ChainForm;
|
||||
let fixture: ComponentFixture<ChainForm>;
|
||||
|
||||
beforeEach(async () => {
|
||||
TestBed.overrideComponent(ImageUploader, {
|
||||
remove: { imports: [ImageUploader] },
|
||||
add: { imports: [ImageUploaderMock] },
|
||||
});
|
||||
|
||||
await TestBed.configureTestingModule({
|
||||
imports: [ChainForm],
|
||||
providers: [provideTranslateService()]
|
||||
})
|
||||
.compileComponents();
|
||||
|
||||
fixture = TestBed.createComponent(ChainForm);
|
||||
component = fixture.componentInstance;
|
||||
await fixture.whenStable();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should populate form with emitted files', async () => {
|
||||
const FILE_MOCK = new File([], 'mock');
|
||||
const patchValueSpy = vi.spyOn(component.form().controls.image, 'patchValue');
|
||||
const imageUploaderComp: ImageUploaderMock = fixture.debugElement.query(By.css('app-image-uploader')).componentInstance;
|
||||
imageUploaderComp.file.emit(FILE_MOCK);
|
||||
await fixture.whenStable();
|
||||
expect(patchValueSpy).toHaveBeenCalledExactlyOnceWith(FILE_MOCK);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user