@signatu/policy
Version:
signatu policy components
40 lines • 1.74 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
var common_lib_1 = require("@signatu/common-lib");
var __1 = require("../..");
describe('Markdown', function () {
var text;
var val = '#foobar \n\n * one\n * two';
beforeEach(function () {
text = new __1.MarkdownContent(val, new common_lib_1.Language('en'));
text.ref = "https://foo.bar";
});
describe('serializes', function () {
it('correctly toJSON()', function () {
var textJSON = text.toJSON();
expect(textJSON.contentType).toEqual(__1.ContentType.MARKDOWN);
expect(textJSON.type).toEqual(__1.ContentType.MARKDOWN);
expect(textJSON.language).toEqual('en');
expect(textJSON.value).toEqual(val);
expect(textJSON.value).toContain('foobar');
expect(textJSON.ref).toContain('https://foo.bar');
});
it('correctly with stringify()', function () {
var s = JSON.stringify(text);
expect(s).toContain("\"value\":\"#foobar \\n\\n * one\\n * two\"");
expect(s).toContain("\"contentType\":\"" + __1.ContentType.MARKDOWN + "\"");
expect(s).toContain("\"type\":\"" + __1.ContentType.MARKDOWN + "\"");
expect(s).toContain('"language":"en"');
});
});
describe('deserializes', function () {
it('correctly', function () {
var s = JSON.stringify(text);
var json = JSON.parse(s);
var parsed = __1.MarkdownContent.fromJSON(json);
// Use equals() to avoid looking at the Converter object
expect(text.equals(parsed)).toEqual(true);
});
});
});
//# sourceMappingURL=markdown.test.js.map
;