A clean and minimal youtube frontend, without all the ads and whistles
JavaScript
test: channels-list web-component
Christian Feibb40aa3e99d9
diff --git a/client/components/channels-list.js b/client/components/channels-list.jsindex e7e3af6..3bc7cb6 100644--- a/client/components/channels-list.js+++ b/client/components/channels-list.js@@ -53,7 +53,8 @@ class ChannelsList extends HTMLElement {channelClick (event) {const $searchInput = document.querySelector('#search')if (!$searchInput) return- const channel = `@${event.target.innerText}`+ const channel = `@${event.target.innerText || event.target.innerHTML}`+ console.log(event.target)const channels = this.querySelectorAll('.channel')if ($searchInput.value === channel) {diff --git a/client/test/channels-list.test.js b/client/test/channels-list.test.jsnew file mode 100644index 0000000..06470bd--- /dev/null+++ b/client/test/channels-list.test.js@@ -0,0 +1,35 @@+/* global describe, it */+import { fixture, html } from '@open-wc/testing'+import { expect } from '@esm-bundle/chai'++import '../components/channels-list.js'++describe('channels-list', () => {+ it('no channels shown', async () => {+ const el = await fixture(html`+ <channels-list></channels-list>+ `)++ expect(el.querySelector('[data-channel]')).eq(null)+ })++ it('channels shown', async () => {+ const el = await fixture(html`+ <channels-list data-list='["channel1"]'></channels-list>+ `)+ expect(el.innerHTML).to.contain('channel1')+ })++ it('clicking on channel sets search input value to channel name', async () => {+ const el = await fixture(html`+ <div>+ <channels-list data-list='["channel1"]'></channels-list>+ <input id="search" type="text">+ </div>+ `)+ const search = el.querySelector('#search')+ const channel = el.querySelector('[data-channel="channel1"]')+ channel.click()+ expect(search.value).to.equal('@channel1')+ })+})