How to use the @dynatrace/barista-components/testing.createComponent function in @dynatrace/barista-components

To help you get started, we’ve selected a few @dynatrace/barista-components examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github dynatrace-oss / barista / components / breadcrumbs / src / breadcrumbs.spec.ts View on Github external
it('should set last property on last child for deprecated dt-breadcrumbs-item', () => {
    const fixture = createComponent(TestBreadcrumbsWithDeprecatedItems);
    const component = fixture.componentInstance;
    const lastValues = component.items.map(
      // tslint:disable-next-line:deprecation
      (item: DtBreadcrumbsItem) => item._lastItem,
    );
    expect(lastValues).toEqual([false, false, true]);
  });
github dynatrace-oss / barista / components / selection-area / src / selection-area.spec.ts View on Github external
beforeEach(fakeAsync(() => {
      fixture = createComponent(BasicTest);
      globalSelectionAreaContainer = getGlobalSelectionAreaHost();
      zone.simulateZoneExit();
      origin = fixture.componentInstance.origin.nativeElement;
    }));
github dynatrace-oss / barista / components / form-field / src / form-field.spec.ts View on Github external
it('should add aria-owns to the label for the associated control', fakeAsync(() => {
    const fixture = createComponent(DtInputLabelTestController);
    const inputElement: HTMLInputElement = fixture.debugElement.query(
      By.css('input'),
    ).nativeElement;
    const labelElement: HTMLInputElement = fixture.debugElement.query(
      By.css('label'),
    ).nativeElement;

    expect(labelElement.getAttribute('aria-owns')).toBe(inputElement.id);
  }));
github dynatrace-oss / barista / components / select / src / select.spec.ts View on Github external
it('should disable itself when control is disabled using the property', fakeAsync(() => {
      const fixture = createComponent(NgModelSelect);

      fixture.componentInstance.isDisabled = true;
      fixture.detectChanges();
      flush();

      const trigger = fixture.debugElement.query(By.css('.dt-select-trigger'))
        .nativeElement;

      trigger.click();
      fixture.detectChanges();

      expect(overlayContainerElement.textContent).toEqual('');
      expect(fixture.componentInstance.select.panelOpen).toBe(false);

      fixture.componentInstance.isDisabled = false;
      fixture.detectChanges();
github dynatrace-oss / barista / components / input / src / input.spec.ts View on Github external
it('has set the default disabled state to false', fakeAsync(() => {
    const fixture = createComponent(DtInputWithDisabled);
    const inputEl = fixture.debugElement.query(By.css('input')).nativeElement;
    expect(inputEl.disabled).toBe(false);
  }));
github dynatrace-oss / barista / components / tabs / src / navigation / tab-navigation-adapter.spec.ts View on Github external
TestBed.configureTestingModule({
      imports: [
        DtTabsModule,
        RouterTestingModule.withRoutes([{ path: '', component: TabComponent }]),
      ],
      declarations: [TabComponent, AppComponent],
      providers: [
        {
          provide: DtTabNavigationAdapter,
          useClass: DtTabRouterFragmentAdapter,
          deps: [Router, ActivatedRoute, Location, LocationStrategy],
        },
      ],
    });
    router = TestBed.get(Router);
    fixture = createComponent(AppComponent);
  });
github dynatrace-oss / barista / components / expandable-section / src / expandable-section.spec.ts View on Github external
beforeEach(async(() => {
      fixture = createComponent(TestApp);
      instanceDebugElement = fixture.debugElement.query(
        By.directive(DtExpandableSection),
      );
      instanceElement = instanceDebugElement.nativeElement;
      expandableSectionInstance = instanceDebugElement.injector.get<
        DtExpandableSection
      >(DtExpandableSection);
    }));
github dynatrace-oss / barista / components / show-more / src / show-more.spec.ts View on Github external
beforeEach(async(() => {
      fixture = createComponent(TestApp);
      testComponent = fixture.componentInstance;
      instanceDebugElement = fixture.debugElement.query(
        By.directive(DtShowMore),
      );
      instanceElement = instanceDebugElement.nativeElement;
    }));
github dynatrace-oss / barista / components / switch / src / switch.spec.ts View on Github external
beforeEach(() => {
      fixture = createComponent(SwitchWithFormControl);

      switchDebugElement = fixture.debugElement.query(By.directive(DtSwitch));
      switchInstance = switchDebugElement.componentInstance;
      testComponent = fixture.debugElement.componentInstance;
      inputElement = switchDebugElement.nativeElement.querySelector(
        'input',
      ) as HTMLInputElement;
    });
github dynatrace-oss / barista / components / chart / src / timestamp / timestamp.spec.ts View on Github external
beforeEach(() => {
      fixture = createComponent(TimestampTestBindingValuesComponent);
      timestamp = fixture.componentInstance.timestamp;
    });