@salla.sa/twilight-components
Version:
Salla Web Component
49 lines (48 loc) • 2.15 kB
JavaScript
/*!
* Crafted with ❤ by Salla
*/
import { newSpecPage } from "@stencil/core/testing";
import { SallaProgressBar } from "../salla-progress-bar";
describe('salla-progress-bar', () => {
let donation = {
target_amount: 500,
collected_amount: 230,
can_donate: true,
custom_amount_enabled: true,
target_date: '2023-02-13T15:23:23.543Z',
target_end_date: '2023-02-25T15:23:23.543Z'
};
it("should build", () => {
expect(new SallaProgressBar()).toBeTruthy();
});
describe("Testing props", () => {
let page;
let element;
it("should set value and target values", async () => {
page = await newSpecPage({
components: [SallaProgressBar],
html: '<salla-progress-bar donation={"target_amount":500,"collected_amount":230,"can_donate":true,"target_date":"2023-02-13T15:23:23.543Z","target_end_date":"2023-02-25T15:23:23.543Z"}></salla-progress-bar>'
});
element = await page.doc.querySelector('salla-progress-bar');
expect(element.value).toBe(donation.collected_amount);
expect(element.target).toBe(donation.target_amount);
});
it("should fail to render", async () => {
page = await newSpecPage({
components: [SallaProgressBar],
html: '<salla-progress-bar donation={"target_amount":500,"collected_amount":230,"can_donate":false,"target_date":"2023-02-13T15:23:23.543Z","target_end_date":"2023-02-25T15:23:23.543Z","target_message":"This is message"}></salla-progress-bar>'
});
element = await page.doc.querySelector('salla-progress-bar');
expect(element.textContent).toBe("");
});
it("should set target message value", async () => {
page = await newSpecPage({
components: [SallaProgressBar],
html: '<salla-progress-bar donation={"target_amount":500,"collected_amount":230,"can_donate":false,"target_date":"2023-02-13T15:23:23.543Z","target_end_date":"2023-02-25T15:23:23.543Z"}></salla-progress-bar>'
});
element = await page.doc.querySelector('salla-progress-bar');
expect(element.textContent).toBe("");
});
});
});
//# sourceMappingURL=salla-progress-bar.spec.js.map