mirror of
https://github.com/discourse/discourse.git
synced 2025-05-21 18:12:32 +08:00
DEV: Remove lazy-yt and replace with lazy-videos (#20722)
- Refactors the old plugin to remove jquery usage - Adds support for Vimeo videos (default on) and Tiktok (experimental and default off)
This commit is contained in:
@ -0,0 +1,49 @@
|
||||
import { setupRenderingTest } from "discourse/tests/helpers/component-test";
|
||||
import hbs from "htmlbars-inline-precompile";
|
||||
import { module, test } from "qunit";
|
||||
import { click, render } from "@ember/test-helpers";
|
||||
|
||||
module("Discourse Lazy Videos | Component | lazy-video", function (hooks) {
|
||||
setupRenderingTest(hooks);
|
||||
|
||||
this.attributes = {
|
||||
url: "https://www.youtube.com/watch?v=kPRA0W1kECg",
|
||||
thumbnail: "thumbnail.jpeg",
|
||||
title: "15 Sorting Algorithms in 6 Minutes",
|
||||
providerName: "youtube",
|
||||
id: "kPRA0W1kECg",
|
||||
};
|
||||
|
||||
test("displays the correct video title", async function (assert) {
|
||||
await render(hbs`<LazyVideo @videoAttributes={{this.attributes}} />`);
|
||||
|
||||
assert.dom(".title-link").hasText(this.attributes.title);
|
||||
});
|
||||
|
||||
test("displays the correct provider icon", async function (assert) {
|
||||
await render(hbs`<LazyVideo @videoAttributes={{this.attributes}} />`);
|
||||
|
||||
assert.dom(".icon.youtube-icon").exists();
|
||||
});
|
||||
|
||||
test("loads the iframe when clicked", async function (assert) {
|
||||
await render(hbs`<LazyVideo @videoAttributes={{this.attributes}}/>`);
|
||||
assert.dom(".lazy-video-container.video-loaded").doesNotExist();
|
||||
|
||||
await click(".video-thumbnail.youtube");
|
||||
assert.dom(".lazy-video-container.video-loaded iframe").exists();
|
||||
});
|
||||
|
||||
test("accepts an optional onLoadedVideo callback function", async function (assert) {
|
||||
this.set("foo", 1);
|
||||
this.set("onLoadedVideo", () => this.set("foo", 2));
|
||||
|
||||
await render(
|
||||
hbs`<LazyVideo @videoAttributes={{this.attributes}} @onLoadedVideo={{this.onLoadedVideo}} />`
|
||||
);
|
||||
assert.strictEqual(this.foo, 1);
|
||||
|
||||
await click(".video-thumbnail.youtube");
|
||||
assert.strictEqual(this.foo, 2);
|
||||
});
|
||||
});
|
Reference in New Issue
Block a user