How to use the @angular/platform-browser.By.css function in @angular/platform-browser

To help you get started, we’ve selected a few @angular/platform-browser 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 sbb-design-systems / sbb-angular / projects / sbb-esta / angular-public / radio-button / src / radio-button / radio-button.component.spec.ts View on Github external
it('should be mutual exclusive', () => {
    const radioButtons = modelComponentFixture.debugElement.queryAll(
      By.directive(RadioButtonComponent)
    );
    radioButtons[0].query(By.css('input[type="radio"]')).nativeElement.click();

    let radioButtonChecked = modelComponentFixture.debugElement.queryAll(By.css('input:checked'));
    expect(radioButtonChecked.length).toBe(1);

    radioButtons[1].query(By.css('input[type="radio"]')).nativeElement.click();

    radioButtonChecked = modelComponentFixture.debugElement.queryAll(By.css('input:checked'));
    expect(radioButtonChecked.length).toBe(1);
  });
github ike18t / ng-mocks / lib / mock-pipe / mock-pipe.spec.ts View on Github external
it('should not display the word hi that is output by the unmocked pipe, because it is now mocked', () => {
    expect(fixture.debugElement.query(By.css('#anotherExamplePipe')).nativeElement.innerHTML).toEqual('');
  });
github devconcept / ng-shopping-cart / src / components / cart-showcase / cart-showcase.component.spec.ts View on Github external
it('should allow to override the format at component level', () => {
      component.items = [new BaseCartItem({id: 1, name: 'Test item', quantity: 1, price: 10.})];
      fixture.detectChanges();
      const item = fixture.debugElement.query(By.css('.showcase-item.default-sc-item'));
      expect(item).toBeTruthy();
      const price = item.query(By.css('.default-sc-price'));
      expect(price.nativeElement.innerText).toEqual('$10.00');
      component.localeFormat = 'EUR';
      fixture.detectChanges();
      expect(price.nativeElement.innerText).toBe('€10.00');
    });
github SAP / fundamental-ngx / libs / platform / src / lib / components / search-input / search-input.component.spec.ts View on Github external
it('should not show the "category dropdown" if "categoryValues" is set with no items', () => {
        host.placeholder = 'Search';
        host.suggestions = [{ value: 'Apple' }, { value: 'Banana' }, { value: 'Carrot' }];
        host.categories = [];
        fixture.detectChanges();

        const categoryDropdown = fixture.debugElement.queryAll(By.css('.search-input__category-dropdown'));
        expect(categoryDropdown.length).toBe(0);
    });
github fabric8-ui / fabric8-ui / packages / fabric8-ui / src / app / space / create / deployments / apps / deployment-card-container.component.spec.ts View on Github external
it('should still display the application title properly', (): void => {
      const el: HTMLElement = testContext.fixture.debugElement.query(
        By.css('.not-deployed-application-title'),
      ).nativeElement;
      expect(el.textContent.trim()).toEqual('app');
    });
  });
github sbb-design-systems / sbb-angular / projects / sbb-esta / angular-public / src / lib / checkbox-panel / checkbox-panel / checkbox-panel.component.spec.ts View on Github external
it('should checked if model is true', async () => {
    const opt1: CheckboxPanelComponent = modelComponent.optionSelections.toArray()[0];
    const opt2: CheckboxPanelComponent = modelComponent.optionSelections.toArray()[1];

    modelComponent.checkValue1 = true;
    modelComponentFixture.detectChanges();

    await modelComponentFixture.whenStable();

    expect(opt1.checked).toBe(true);
    expect(modelComponent.checkValue1).toBe(true);

    const element = modelComponentFixture.debugElement.queryAll(By.css('label'))[1];
    dispatchEvent(element.nativeElement, createMouseEvent('click'));
    modelComponentFixture.detectChanges();

    await modelComponentFixture.whenStable();
    expect(opt2.checked).toBe(true);
    expect(modelComponent.checkValue2).toBe(true);
  });
});
github dotCMS / core-web / src / app / view / components / login / reset-password-component / reset-password.component.spec.ts View on Github external
it('should load form labels correctly', () => {
        const header: DebugElement = de.query(By.css('h3'));
        const inputs: DebugElement[] = de.queryAll(By.css('span[dotmdinputtext] label'));
        const button: DebugElement = de.query(By.css('button'));

        expect(header.nativeElement.innerHTML).toEqual('Password Reset');
        expect(inputs[0].nativeElement.innerHTML).toContain('Enter Password');
        expect(inputs[1].nativeElement.innerHTML).toContain('Confirm Password');
        expect(button.nativeElement.innerHTML).toContain('Change Password');
    });
github SAP / cloud-commerce-spartacus-storefront / projects / storefrontlib / src / lib / cms-lib / category-navigation / category-navigation.component.spec.ts View on Github external
it('should display correct number of submenus', () => {
      const list: HTMLElement = nav.query(By.css('.cx-navigation__list'))
        .nativeElement;
      expect(list.childElementCount).toBe(2);
    });
  });
github GetTerminus / terminus-ui / terminus-ui / checkbox / src / checkbox.component.spec.ts View on Github external
test(`checkbox is not disabled`, () => {
        hostComponent.disabled = false;
        fixture.detectChanges();
        expect(component.isDisabled).toEqual(false);
        const checkbox = fixture.debugElement.query(By.css('#mat-checkbox-5-input'));
        expect(checkbox.nativeElement.disabled).toEqual(false);
      });
github ng-alain / delon / packages / chart / number-info / number-info.spec.ts View on Github external
function isExists(cls: string, stauts: boolean = true) {
    if (stauts) {
      expect(dl.query(By.css(cls))).not.toBeNull();
    } else {
      expect(dl.query(By.css(cls))).toBeNull();
    }
  }