diff --git a/src/components/footer-rel.test.ts b/src/components/footer-rel.test.ts new file mode 100644 index 0000000000..e29bcee5b7 --- /dev/null +++ b/src/components/footer-rel.test.ts @@ -0,0 +1,33 @@ +import { describe, expect, it } from '@jest/globals'; +import { screen, within } from '@testing-library/dom'; +import { html } from 'lit'; +import { fixture } from '../../__tests__/helpers/fixtures'; +import '../components/footer-rel'; +import { notifications, subscribeNote } from '../utils/data'; + +describe('footer-rel', () => { + it('defines a component', () => { + expect(customElements.get('footer-rel')).toBeDefined(); + }); + + it('renders subscription section', async () => { + const { shadowRootForWithin } = await fixture( + html``, + ); + const withinShadowRoot = within(shadowRootForWithin); + const subscriptionHeading = withinShadowRoot.getByText(notifications.subscribe); + const subscriptionNote = withinShadowRoot.getByText(subscribeNote); + + expect(screen.getByTestId('footer-rel')).toBeInTheDocument(); + expect(subscriptionHeading).toBeInTheDocument(); + expect(subscriptionHeading).toHaveClass('col-heading'); + expect(subscriptionNote).toBeInTheDocument(); + }); + + it('renders without errors', async () => { + const { element } = await fixture(html``); + + expect(element).toBeInTheDocument(); + expect(element.shadowRoot).toBeDefined(); + }); +}); diff --git a/src/elements/footer-rel.ts b/src/components/footer-rel.ts similarity index 56% rename from src/elements/footer-rel.ts rename to src/components/footer-rel.ts index 4b45f83e45..8c80323821 100644 --- a/src/elements/footer-rel.ts +++ b/src/components/footer-rel.ts @@ -1,13 +1,16 @@ -import { customElement, property } from '@polymer/decorators'; -import { html, PolymerElement } from '@polymer/polymer'; +import { css, html } from 'lit'; +import { customElement, property } from 'lit/decorators.js'; +import { repeat } from 'lit/directives/repeat.js'; import { footerRelBlock, notifications, subscribeNote } from '../utils/data'; -import './subscribe-form-footer'; +import { ThemedElement } from '../components/themed-element'; +import '../elements/subscribe-form-footer'; @customElement('footer-rel') -export class FooterRel extends PolymerElement { - static get template() { - return html` - + `, + ]; + } - + override render() { + return html` + ${repeat( + this.footerRelBlock, + (footerRel) => footerRel.title, + (footerRel) => html` +
+
${footerRel.title}
+ +
+ `, + )}
-
[[notifications.subscribe]]
- [[subscribeNote]] +
${this.notifications.subscribe}
+ ${this.subscribeNote}
`; @@ -93,8 +107,10 @@ export class FooterRel extends PolymerElement { @property({ type: Array }) private footerRelBlock = footerRelBlock; + @property() private subscribeNote = subscribeNote; + @property({ type: Object }) private notifications = notifications; } diff --git a/src/elements/footer-block.ts b/src/elements/footer-block.ts index dc3bd462d2..81578c45dd 100644 --- a/src/elements/footer-block.ts +++ b/src/elements/footer-block.ts @@ -4,7 +4,7 @@ import { html, PolymerElement } from '@polymer/polymer'; import '../utils/icons'; import { scrollToTop } from '../utils/scrolling'; import '../components/footer-nav'; -import './footer-rel'; +import '../components/footer-rel'; import './footer-social'; @customElement('footer-block')