@salla.sa/twilight-components
Version:
Salla Web Component
91 lines (90 loc) • 2.62 kB
JavaScript
/*!
* Crafted with ❤ by Salla
*/
import { newSpecPage } from "@stencil/core/testing";
import { SallaOfferModal } from "../salla-offer-modal";
const products = [{
id: 1,
type: 'Test Type',
status: 'Test Status',
is_available: true,
sku: 'Test SKU',
name: 'Test Name',
price: { amount: 1, currency: 'Test Currency' },
promotion: { title: 'Test Title', sub_title: 'Test Sub Title' },
sale_price: { amount: 1, currency: 'Test Currency' },
regular_price: { amount: 1, currency: 'Test Currency' },
currency: 'Test Currency',
url: 'Test URL',
thumbnail: 'Test Thumbnail',
has_special_price: true,
favorite: true
}];
const offer = {
id: 1,
name: 'Test Offer',
message: 'Test Message',
expiry_date: '2020-01-01',
formatted_date: '2020-01-01',
offer_type: 'Test Offer Type',
status: 'Test Status',
buy: {
type: 'Test Type',
quantity: 1,
products: products
},
//@ts-ignore
get: {
categories: [{
id: 1,
name: 'Test Name',
url: 'Test URL'
}],
products: products,
type: "Test Type",
discount_type: "Test discount type",
}
};
describe('salla offer modal', () => {
it('should build', () => {
expect(new SallaOfferModal()).toBeTruthy();
});
describe('rendering', () => {
let page;
beforeEach(async () => {
page = await newSpecPage({
components: [SallaOfferModal],
html: '<salla-offer-modal></salla-offer-modal>'
});
});
it('should be able to render component', async () => {
await page.waitForChanges();
let component = page.doc.querySelector('salla-offer-modal');
expect(component).toBeDefined();
});
});
describe('checking for methods', () => {
let page;
let element;
beforeEach(async () => {
page = await newSpecPage({
components: [SallaOfferModal],
html: '<salla-offer-modal></salla-offer-modal>',
});
element = page.root.querySelector('salla-offer-modal');
});
it('should be able to call method to open modal', async () => {
await page.root.open(products[0].id);
await page.waitForChanges();
const modal = await element.find('salla-modal');
expect(modal.getAttribute('visible')).not.toBeNull();
});
it('should be able to call method to show offers', async () => {
await page.root.showOffer(offer);
await page.waitForChanges();
const modal = await element.find('.s-modal-title');
expect(modal.innerHTML).toEqual(offer.name);
});
});
});
//# sourceMappingURL=salla-offer-modal.spec.js.map