@pact-foundation/pact
Version:
Pact for all things Javascript
42 lines • 1.76 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const vitest_1 = require("vitest");
const v4_1 = require("../../v4");
const requestBuilder_1 = require("./requestBuilder");
describe('V4 RequestBuilder', () => {
let withRequestBody;
let interaction;
let builder;
beforeEach(() => {
withRequestBody = vitest_1.vi.fn();
interaction = { withRequestBody };
builder = new requestBuilder_1.RequestBuilder(interaction);
});
afterEach(() => {
vitest_1.vi.restoreAllMocks();
});
describe('#xmlBody', () => {
it('calls withRequestBody 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(withRequestBody).toHaveBeenCalledOnce();
expect(withRequestBody).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(withRequestBody).toHaveBeenCalledOnce();
expect(withRequestBody).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=requestBuilder.spec.js.map