Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,18 @@ describe('DSDynamicTypeBindRelationService test suite', () => {
let injector: Injector;

beforeEach(() => {
TestBed.configureTestingModule({
// Return the promise so the module (and its fresh getMockFormBuilderService() spy mock) is fully set up
// before each spec runs; the previous dangling .then() did not await, letting asynchronous module setup
// leak between specs.
return TestBed.configureTestingModule({
imports: [ReactiveFormsModule],
providers: [
{ provide: FormBuilderService, useValue: getMockFormBuilderService() },
{ provide: DsDynamicTypeBindRelationService, useClass: DsDynamicTypeBindRelationService },
{ provide: DynamicFormRelationService },
DISABLED_MATCHER_PROVIDER, HIDDEN_MATCHER_PROVIDER, REQUIRED_MATCHER_PROVIDER
]
}).compileComponents().then();
}).compileComponents();
});

beforeEach(inject([DsDynamicTypeBindRelationService, DynamicFormRelationService],
Expand Down Expand Up @@ -86,7 +89,7 @@ describe('DSDynamicTypeBindRelationService test suite', () => {
it('Should not push undefined bind models', () => {
const testModel = mockInputWithTypeBindModel;
testModel.typeBindRelations = getTypeBindRelations(['boundType']);
spyOn((service as any).formBuilderService, 'getTypeBindModel').and.returnValue(undefined);
((service as any).formBuilderService.getTypeBindModel as jasmine.Spy).and.returnValue(undefined);

const relatedModels = service.getRelatedFormModel(testModel);

Expand Down Expand Up @@ -143,7 +146,7 @@ describe('DSDynamicTypeBindRelationService test suite', () => {
opposingMatch: HIDDEN_MATCHER.match,
onChange: jasmine.createSpy('onChange')
};
spyOn((service as any).formBuilderService, 'getTypeBindModel').and.returnValue(undefined);
((service as any).formBuilderService.getTypeBindModel as jasmine.Spy).and.returnValue(undefined);

const hasMatch = service.matchesCondition(relation, visibleMatcher);

Expand All @@ -159,7 +162,7 @@ describe('DSDynamicTypeBindRelationService test suite', () => {
opposingMatch: MATCH_VISIBLE,
onChange: jasmine.createSpy('onChange')
};
spyOn((service as any).formBuilderService, 'getTypeBindModel').and.returnValue(undefined);
((service as any).formBuilderService.getTypeBindModel as jasmine.Spy).and.returnValue(undefined);

const hasMatch = service.matchesCondition(relation, hiddenMatcher);

Expand All @@ -185,8 +188,8 @@ describe('DSDynamicTypeBindRelationService test suite', () => {
onChange: jasmine.createSpy('onChange')
};
(service as any).dynamicMatchers = [visibleMatcher];
spyOn((service as any).formBuilderService, 'getTypeBindModel').and.callFake(() => bindModelAvailable ? bindModel : undefined);
spyOn((service as any).formBuilderService, 'getTypeBindModelUpdates').and.returnValue(bindModelUpdates$.asObservable());
((service as any).formBuilderService.getTypeBindModel as jasmine.Spy).and.callFake(() => bindModelAvailable ? bindModel : undefined);
((service as any).formBuilderService.getTypeBindModelUpdates as jasmine.Spy).and.returnValue(bindModelUpdates$.asObservable());

const subscriptions = service.subscribeRelations(testModel, dcTypeControl);
expect(subscriptions.length).toBe(1);
Expand Down Expand Up @@ -220,8 +223,8 @@ describe('DSDynamicTypeBindRelationService test suite', () => {
onChange: jasmine.createSpy('onChange')
};
(service as any).dynamicMatchers = [hiddenMatcher];
spyOn((service as any).formBuilderService, 'getTypeBindModel').and.callFake(() => bindModelAvailable ? bindModel : undefined);
spyOn((service as any).formBuilderService, 'getTypeBindModelUpdates').and.returnValue(bindModelUpdates$.asObservable());
((service as any).formBuilderService.getTypeBindModel as jasmine.Spy).and.callFake(() => bindModelAvailable ? bindModel : undefined);
((service as any).formBuilderService.getTypeBindModelUpdates as jasmine.Spy).and.returnValue(bindModelUpdates$.asObservable());

const subscriptions = service.subscribeRelations(testModel, dcTypeControl);
expect(subscriptions.length).toBe(1);
Expand Down Expand Up @@ -254,8 +257,8 @@ describe('DSDynamicTypeBindRelationService test suite', () => {
onChange: jasmine.createSpy('onChange')
};
(service as any).dynamicMatchers = [visibleMatcher];
spyOn((service as any).formBuilderService, 'getTypeBindModel').and.callFake(() => bindModelAvailable ? bindModel : undefined);
spyOn((service as any).formBuilderService, 'getTypeBindModelUpdates').and.returnValue(bindModelUpdates$.asObservable());
((service as any).formBuilderService.getTypeBindModel as jasmine.Spy).and.callFake(() => bindModelAvailable ? bindModel : undefined);
((service as any).formBuilderService.getTypeBindModelUpdates as jasmine.Spy).and.returnValue(bindModelUpdates$.asObservable());

const subscriptions = service.subscribeRelations(testModel, dcTypeControl);
expect(visibleMatcher.onChange).toHaveBeenCalledWith(false, testModel, dcTypeControl, jasmine.anything());
Expand Down
Loading