From 37f9d5aa29c7f0eb1b4f25c6c47cf31ab03545e9 Mon Sep 17 00:00:00 2001 From: Kyle Shockey Date: Thu, 3 Aug 2017 17:13:58 -0700 Subject: [PATCH] Add tests --- test/core/plugins/samples/fn.js | 63 +++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/test/core/plugins/samples/fn.js b/test/core/plugins/samples/fn.js index a2d01876..e5032b50 100644 --- a/test/core/plugins/samples/fn.js +++ b/test/core/plugins/samples/fn.js @@ -554,6 +554,69 @@ describe("createXMLExample", function () { expect(sut(definition, { includeReadOnly: false })).toEqual(expected) }) + it("returns object with readonly fields for parameter, with includeReadOnly", function () { + var expected = "\n\n\t0\n\tstring\n" + var definition = { + type: "object", + properties: { + id: { + type: "integer" + }, + dog: { + readOnly: true, + type: "string" + } + }, + xml: { + name: "animals" + } + } + + expect(sut(definition, { includeReadOnly: true })).toEqual(expected) + }) + + it("returns object without writeonly fields for parameter", function () { + var expected = "\n\n\t0\n" + var definition = { + type: "object", + properties: { + id: { + type: "integer" + }, + dog: { + writeOnly: true, + type: "string" + } + }, + xml: { + name: "animals" + } + } + + expect(sut(definition)).toEqual(expected) + }) + + it("returns object with writeonly fields for parameter, with includeWriteOnly", function () { + var expected = "\n\n\t0\n\tstring\n" + var definition = { + type: "object", + properties: { + id: { + type: "integer" + }, + dog: { + writeOnly: true, + type: "string" + } + }, + xml: { + name: "animals" + } + } + + expect(sut(definition, { includeWriteOnly: true })).toEqual(expected) + }) + it("returns object with passed property as attribute", function () { var expected = "\n\n\tstring\n" var definition = {