@pact-foundation/pact
Version:
Pact for all things Javascript
42 lines • 1.77 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const vitest_1 = require("vitest");
const v4_1 = require("../../v4");
const responseBuilder_1 = require("./responseBuilder");
describe('V4 ResponseBuilder', () => {
let withResponseBody;
let interaction;
let builder;
beforeEach(() => {
withResponseBody = vitest_1.vi.fn();
interaction = { withResponseBody };
builder = new responseBuilder_1.ResponseBuilder(interaction);
});
afterEach(() => {
vitest_1.vi.restoreAllMocks();
});
describe('#xmlBody', () => {
it('calls withResponseBody with application/xml content type', () => {
const body = new v4_1.XmlBuilder('1.0', 'UTF-8', 'root').build((el) => {
el.appendElement('item', new Map(), 'value');
});
builder.xmlBody(body);
expect(withResponseBody).toHaveBeenCalledOnce();
expect(withResponseBody).toHaveBeenCalledWith(body, 'application/xml');
});
it('supports XmlBuilder with matchers', () => {
const body = new v4_1.XmlBuilder('1.0', 'UTF-8', 'items').build((el) => {
el.eachLike('item', new Map(), (item) => item.appendText('value'));
});
builder.xmlBody(body);
expect(withResponseBody).toHaveBeenCalledOnce();
expect(withResponseBody).toHaveBeenCalledWith(body, 'application/xml');
});
it('returns the builder for chaining', () => {
const body = new v4_1.XmlBuilder('1.0', 'UTF-8', 'root').build(() => { });
const result = builder.xmlBody(body);
expect(result).toBe(builder);
});
});
});
//# sourceMappingURL=responseBuilder.spec.js.map