🐛 Fixed unnecessary "unsaved changes" modal when using HR cards

no issue

- the `hr` mobiledoc card does not specify an `absoluteToRelative` or `relativeToAbsolute` transformer function so falls back to the default transformer
- the default transformer function's arguments were not correct which meant that the UrlUtils object was replacing the card's typical empty-object payload
- the card's payload changing when saving mobiledoc was triggering the editor's unsaved changes warning because the API response no longer matched what was in the editor
This commit is contained in:
Kevin Ansfield 2020-01-22 11:55:57 +00:00
parent 6e024331eb
commit 8b787ac803
2 changed files with 13 additions and 1 deletions

View File

@ -1,7 +1,7 @@
let urlUtils;
module.exports = function createCard(card) {
const defaultTransformer = function (payload) {
const defaultTransformer = function (urlUtils, payload) {
return payload;
};

View File

@ -13,4 +13,16 @@ describe('HR card', function () {
serializer.serialize(card.render(opts)).should.match('<hr>');
});
it('transforms urls absolute to relative', function () {
let payload = {};
const transformed = card.absoluteToRelative(payload, {});
transformed.should.deepEqual({});
});
it('transforms urls relative to absolute', function () {
let payload = {};
const transformed = card.relativeToAbsolute(payload, {});
transformed.should.deepEqual({});
});
});