All files / src/app/pages/registration/formly/registration-heading-field registration-heading-field.component.ts

100% Statements 8/8
75% Branches 3/4
100% Functions 3/3
100% Lines 7/7

Press n or j to go to the next uncovered block, b, p or k for the previous block.

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 331x 1x   1x                             1x 2x           1x       1x      
import { ChangeDetectionStrategy, Component } from '@angular/core';
import { FieldType } from '@ngx-formly/core';
 
const sizes = ['h1', 'h2'];
 
/**
 * Type that displays a section heading.
 *
 * @props **heading** the primary heading text. Will be translated.
 * @props **subheading** the secondary heading text. Wil be translated.
 * @props **headingSize** determines whether the heading should be rendered with an <h1> or <h2> tag.
 * @props **showRequiredInfo** determines whether a message explaining the required star should be shown.
 */
@Component({
  selector: 'ish-registration-heading-field',
  templateUrl: './registration-heading-field.component.html',
  changeDetection: ChangeDetectionStrategy.OnPush,
})
export class RegistrationHeadingFieldComponent extends FieldType {
  private dto = {
    headingSize: 'h1',
    showRequiredInfo: false,
  };
 
  get size() {
    return sizes.includes(this.props.headingSize) ? this.props.headingSize : this.dto.headingSize;
  }
 
  get showRequiredInfo() {
    return this.props.showRequiredInfo ?? this.dto.showRequiredInfo;
  }
}