Skip to content
This repository was archived by the owner on Aug 25, 2020. It is now read-only.

Commit 48a0426

Browse files
committed
chore(tests): fixed tests and references
1 parent 8733e27 commit 48a0426

19 files changed

+705
-386
lines changed

dist/ngx-forms.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/app/app.module.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ export class NgxFormModule {
6161

6262

6363
// TODO: next
64-
// break down Nav module into Groups module
6564
// unit tests
6665
// create different default layouts for ngx-forms
6766
// make nav part of group-layout
67+
68+
// individual field layout ????

src/app/dynamic-field/dynamic-field.directive.spec.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,19 @@ import { FormsModule, ReactiveFormsModule, FormGroup, FormBuilder, FormControl }
55
import { ComponentFixture, TestBed } from '@angular/core/testing';
66
import { DynamicFieldDirective } from "./dynamic-field.directive"
77
import { By } from '@angular/platform-browser';
8-
import { FieldConfig, FieldDictionary, FIELD_DICT_TOKEN } from "../../types";
9-
import { FormInputComponent } from "../form-input/form-input.component";
10-
import { FormInputHiddenComponent } from '../form-hidden/form-hidden.component'; // mock this inputs instead of importing
8+
import { FieldConfig, FieldDictionary, FIELD_DICT_TOKEN, Field } from "../../types";
9+
10+
@Component({
11+
selector: 'form-input',
12+
template: '<div [formGroup]="group"><input [formControlName]="field.name"></div>'
13+
})
14+
export class FormInputComponent implements Field {
15+
field: FieldConfig;
16+
group: FormGroup;
17+
}
1118

1219
const defaultInputs: FieldDictionary = {
1320
text: FormInputComponent,
14-
hidden: FormInputHiddenComponent
1521
}
1622

1723
@Component({

src/app/dynamic-field/dynamic-field.directive.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,12 @@ export class DynamicFieldDirective implements Field, OnInit, OnDestroy {
2121
ngOnInit() {
2222
if (!this.group) { throw new Error('group is not set'); }
2323
if (!this.inputs[this.field.type]) { throw new Error(`Input with type "${this.field.type}" was not found`); }
24-
24+
2525
const componentReference = this.inputs[this.field.type];
2626
const component = this.resolver.resolveComponentFactory<Field>(componentReference);
2727
this.component = this.container.createComponent(component);
2828
this.component.instance.field = this.field;
2929
this.component.instance.group = this.group;
30-
31-
console.log('creating control ', this.field.type)
32-
3330
this.component.instance.model = this.model;
3431
this.group.addControl(this.field.name, this.createControl(this.field));
3532

0 commit comments

Comments
 (0)