Jack Maclennan Portfolio
    Preparing search index...

    Fixture for CardListItem component.

        for (const [index, item] of EXPERIENCE_ITEMS.entries()) {
    const cardItem = new CardListItem(cardList.getWrapper(), cardList.getListItemByIndex(index));
    await cardItem.expectTitleText(item.title);
    await cardItem.expectSubtitleText(item.subtitle);
    }

    Provides method helpers for locating child elements.

    export class CardListItem implements Component {
    /** @public Component wrapper. */
    private readonly cardItem: Locator;
    /** @public Card title element. */
    private readonly title: Locator;
    /** @public Card subtitle element. */
    private readonly subtitle: Locator;

    /**
    * @param parent - Parent element (card-list-item).
    */
    public constructor(
    public readonly parent: Locator,
    cardItem: Locator
    ) {
    this.cardItem = cardItem;
    this.title = this.cardItem.getByRole('heading');
    this.subtitle = this.cardItem.locator('p');
    }

    /** Getter method. @returns {@link cardItem}. */
    public getWrapper(): Locator {
    return this.cardItem;
    }

    /** Testing helper method. */
    public async rendersCorrectly(): Promise<boolean> {
    await expect(this.getTitle(), 'card title should be visible').toBeVisible();
    await expect(this.getSubtitle(), 'card subtitle should be visible').toBeVisible();
    return true;
    }

    /** Getter method. @returns {@link title}. */
    getTitle(): Locator {
    return this.title;
    }

    /** Getter method. @returns {@link subtitle}. */
    getSubtitle(): Locator {
    return this.subtitle;
    }

    /** Assert that the title has the expected text. */
    async expectTitleText(text: string): Promise<void> {
    await expect(this.getTitle()).toHaveText(text);
    }

    /** Assert that the subtitle has the expected text. */
    async expectSubtitleText(text: string): Promise<void> {
    await expect(this.getSubtitle()).toHaveText(text);
    }
    }

    Implements

    Index

    Constructors

    Properties

    cardItem: Locator

    Component wrapper.

    title: Locator

    Card title element.

    subtitle: Locator

    Card subtitle element.

    parent: Locator

    Parent element (card-list-item).

    Methods

    • Assert that the title has the expected text.

      Parameters

      • text: string

      Returns Promise<void>

    • Assert that the subtitle has the expected text.

      Parameters

      • text: string

      Returns Promise<void>