31 lines
908 B
JavaScript
31 lines
908 B
JavaScript
import assert from 'node:assert/strict';
|
|
import test from 'node:test';
|
|
import { bindDraftActions } from '../src/Modules/GrapesJS/resources/assets/js/draft-actions.js';
|
|
|
|
function button() {
|
|
let clickHandler;
|
|
return {
|
|
addEventListener(eventName, handler) {
|
|
assert.equal(eventName, 'click');
|
|
clickHandler = handler;
|
|
},
|
|
click() {
|
|
clickHandler();
|
|
},
|
|
};
|
|
}
|
|
|
|
test('draft action saves edits and publishes only after confirmation', () => {
|
|
const saveButton = button();
|
|
const publishButton = button();
|
|
const actions = [];
|
|
let confirmation = false;
|
|
|
|
bindDraftActions(saveButton, publishButton, publishAfterSave => actions.push(publishAfterSave), () => confirmation);
|
|
saveButton.click();
|
|
publishButton.click();
|
|
confirmation = true;
|
|
publishButton.click();
|
|
|
|
assert.deepEqual(actions, [false, true]);
|
|
}); |