Files
piratepoet/mailpoet/tests/javascript-newsletter-editor/newsletter-editor/blocks/woocommerce-content.spec.js
Jan Jakes d664f60e4b Rename all non-snake-case JS/TS imports
[MAILPOET-4938]
2023-10-02 13:05:20 +02:00

73 lines
1.9 KiB
JavaScript

import { App } from 'newsletter-editor/app';
import WCContentBlock from 'newsletter-editor/blocks/woocommerce-content';
const expect = global.expect;
const sinon = global.sinon;
var EditorApplication = App;
describe('WoocommerceContent', function () {
describe('model', function () {
var model;
var sandbox;
beforeEach(function () {
global.stubChannel(EditorApplication);
global.stubConfig(EditorApplication, {
blockDefaults: {},
});
global.stubAvailableStyles(EditorApplication);
model = new WCContentBlock.BlockModel();
sandbox = sinon.createSandbox();
});
afterEach(function () {
delete EditorApplication.getChannel;
sandbox.restore();
});
it('has woocommerceContent type', function () {
expect(model.get('type')).to.equal('woocommerceContent');
});
it('has titleColor', function () {
expect(model.get('styles.titleColor')).to.match(
/^(#[abcdef0-9]{6})|transparent$/,
);
});
it('uses defaults from config when they are set', function () {
global.stubConfig(EditorApplication, {
blockDefaults: {
woocommerceContent: {
styles: {
titleColor: '#567890',
},
},
},
});
model = new WCContentBlock.BlockModel();
expect(model.get('styles.titleColor')).to.equal('#567890');
});
});
describe('block view', function () {
var model;
var view;
beforeEach(function () {
global.stubChannel(EditorApplication);
global.stubConfig(EditorApplication);
global.stubAvailableStyles(EditorApplication);
model = new WCContentBlock.BlockModel();
view = new WCContentBlock.BlockView({ model: model });
});
it('renders', function () {
expect(view.render).to.not.throw();
expect(view.$('.mailpoet_woocommerce_content')).to.have.length(1);
});
});
});