UNPKG

@signatu/policy

Version:
45 lines 2 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var common_lib_1 = require("@signatu/common-lib"); var __1 = require("../.."); describe('Image', function () { var image; var url = "https://foo.bar/2134"; var english = new common_lib_1.Language('en'); beforeEach(function () { image = new __1.Image('my image', url, english, 'background'); image.ref = "https://foo.bar"; }); describe('serializes', function () { it('correctly toJSON()', function () { var imageJSON = image.toJSON(); expect(imageJSON.contentType).toEqual(__1.ContentType.IMAGE); expect(imageJSON.type).toEqual(__1.ContentType.IMAGE); expect(imageJSON.url).toEqual(url); expect(imageJSON.title).toEqual('my image'); expect(imageJSON.language).toEqual('en'); expect(imageJSON.value).toContain("img src=\"" + url + "\""); expect(imageJSON.cssClass).toEqual('background'); expect(imageJSON.ref).toEqual('https://foo.bar'); }); it('correctly with stringify()', function () { var s = JSON.stringify(image); expect(s).toContain("\"value\":\"<img src=\\\"" + url + "\\\""); expect(s).toContain("\"contentType\":\"" + __1.ContentType.IMAGE + "\""); expect(s).toContain("\"type\":\"" + __1.ContentType.IMAGE + "\""); expect(s).toContain('"title":"my image"'); expect(s).toContain("\"url\":\"" + url + "\""); expect(s).toContain('"language":"en"'); expect(s).toContain('"cssClass":"background"'); }); }); describe('deserializes', function () { it('correctly', function () { var s = JSON.stringify(image); var json = JSON.parse(s); var parsedImage = __1.Image.fromJSON(json); expect(image).toEqual(parsedImage); }); }); }); //# sourceMappingURL=image.test.js.map