diff --git a/test/core/plugins/samples/fn.js b/test/core/plugins/samples/fn.js
index fa352e852b6..bbf25b62b04 100644
--- a/test/core/plugins/samples/fn.js
+++ b/test/core/plugins/samples/fn.js
@@ -539,6 +539,19 @@ describe("createXMLExample", function () {
expect(sut(definition)).toEqual(expected)
})
+ it("returns value wrapped by `CDATA` when passing {CDATA: true}", function () {
+ var expected = "\n"
+ var definition = {
+ type: "string",
+ example: "foo&bar 1<2",
+ xml: {
+ CDATA: true
+ }
+ }
+
+ expect(sut(definition)).toEqual(expected)
+ })
+
it("sets first enum if provided", function () {
var expected = "\none"
var definition = {
@@ -902,6 +915,27 @@ describe("createXMLExample", function () {
expect(sut(definition)).toEqual(expected)
})
+
+ it("returns array with example values wrapped by `CDATA` when passing {CDATA: true}", function () {
+ var expected = "\n\n\t\n\t\n"
+ var definition = {
+ type: "array",
+ items: {
+ type: "string",
+ xml: {
+ CDATA: true,
+ name: "animal"
+ }
+ },
+ "example": [ "foo&bar", "1<2" ],
+ xml: {
+ wrapped: true,
+ name: "animals"
+ }
+ }
+
+ expect(sut(definition)).toEqual(expected)
+ })
})
describe("object", function () {
@@ -1300,5 +1334,91 @@ describe("createXMLExample", function () {
expect(sut(definition)).toEqual(expected)
})
+
+ it("returns object with example value wrapped by `CDATA` when passing {CDATA: true}", function () {
+ var expected = "\n\n\t\n\t\n"
+ var definition = {
+ type: "object",
+ properties: {
+ foo: {
+ type: "string",
+ xml: {
+ CDATA: true
+ }
+ },
+ bar:{
+ type: "string",
+ xml: {
+ CDATA: true
+ }
+ }
+ },
+ xml: {
+ name: "bob"
+ },
+ example: {
+ foo: "&bar",
+ bar: "<2"
+ }
+ }
+
+ expect(sut(definition)).toEqual(expected)
+ })
+
+ it("returns object with 2 properties those values wrapped by `CDATA` when passing {CDATA: true}", function () {
+ var expected = "\n\n\t\n\t\n"
+ var definition = {
+ properties: {
+ foo: {
+ type: "string",
+ xml: {
+ CDATA: true
+ }
+ },
+ bar: {
+ type: "string",
+ xml: {
+ CDATA: true
+ }
+ }
+ },
+ xml: {
+ name: "bob"
+ }
+ }
+
+ expect(sut(definition)).toEqual(expected)
+ })
+
+ it("returns object with additional props equals `true` and those values wrapped by `CDATA` when the defs passing {CDATA: true}", function () {
+ var expected = "\n\n\t\n"
+ var definition = {
+ additionalProperties: true,
+ xml: {
+ name: "animals",
+ wrapped: true,
+ CDATA: true
+ }
+ }
+
+ expect(sut(definition)).toEqual(expected)
+ })
+
+ it("returns object with additional props those values wrapped by `CDATA` when passing {CDATA: true}", function () {
+ var expected = "\n\n\t\n"
+ var definition = {
+ additionalProperties: {
+ type: "string",
+ xml: {
+ CDATA: true
+ }
+ },
+ xml: {
+ name: "animals"
+ }
+ }
+
+ expect(sut(definition)).toEqual(expected)
+ })
})
})