How to use the @angular/platform-browser-dynamic/testing/private_import_platform-browser.getDOM function in @angular/platform-browser-dynamic

To help you get started, we’ve selected a few @angular/platform-browser-dynamic 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 springboot-angular2-tutorial / angular2-app / src / app / pages / home / feed / feed.component.spec.ts View on Github external
it('can show feed', () => {
    expect(cmpDebugElement).toBeTruthy();

    const cmp: FeedComponent = cmpDebugElement.componentInstance;
    expect(cmp.feed.length).toEqual(2);

    const el = cmpDebugElement.nativeElement;
    expect(getDOM().querySelectorAll(el, 'li').length).toEqual(2);

    const avatarLink = getDOM().querySelector(el, 'li > a[href="/users/1"]');
    expect(avatarLink).toBeTruthy();

    const userLink = getDOM().querySelector(el, 'li > span > a[href="/users/1"]');
    expect(userLink).toBeTruthy();

    const gravatarDebugElement = cmpDebugElement.query(By.directive(GravatarComponent));
    expect(gravatarDebugElement).toBeTruthy();
    expect(gravatarDebugElement.componentInstance.hash).toEqual('9a3f499f653f7e8d4c5bf3ae0cf6418f');
    expect(gravatarDebugElement.componentInstance.alt).toEqual('test user1');

    const firstItem = getDOM().querySelector(el, 'li');
    expect(firstItem.innerText).toMatch(/test user1/);
    expect(firstItem.innerText).toMatch(/content1/);
    expect(firstItem.innerText).toMatch(/1 day ago/);
github springboot-angular2-tutorial / angular2-app / src / app / pages / home / feed / feed.component.spec.ts View on Github external
const el = cmpDebugElement.nativeElement;
    expect(getDOM().querySelectorAll(el, 'li').length).toEqual(2);

    const avatarLink = getDOM().querySelector(el, 'li > a[href="/users/1"]');
    expect(avatarLink).toBeTruthy();

    const userLink = getDOM().querySelector(el, 'li > span > a[href="/users/1"]');
    expect(userLink).toBeTruthy();

    const gravatarDebugElement = cmpDebugElement.query(By.directive(GravatarComponent));
    expect(gravatarDebugElement).toBeTruthy();
    expect(gravatarDebugElement.componentInstance.hash).toEqual('9a3f499f653f7e8d4c5bf3ae0cf6418f');
    expect(gravatarDebugElement.componentInstance.alt).toEqual('test user1');

    const firstItem = getDOM().querySelector(el, 'li');
    expect(firstItem.innerText).toMatch(/test user1/);
    expect(firstItem.innerText).toMatch(/content1/);
    expect(firstItem.innerText).toMatch(/1 day ago/);
    expect(firstItem.innerText).toMatch(/delete/);

    const lastItem = getDOM().querySelector(el, 'li:last-child');
    expect(lastItem.innerText).not.toMatch(/delete/);
  });