Skip to content

Commit 40c5215

Browse files
committed
test: Added parse tpl tests
1 parent 9a38be0 commit 40c5215

1 file changed

Lines changed: 35 additions & 0 deletions

File tree

test/parseTpl.test.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,26 @@ describe('parseTpl', () => {
196196
const result = parseTpl(dto);
197197
expect(result).toBe('{{{trainMonetaryAmount}}}');
198198
});
199+
200+
it('keeps placeholder text when casing getter changes during replacement', () => {
201+
const options = {};
202+
let readCount = 0;
203+
Object.defineProperty(options, 'casing', {
204+
get() {
205+
readCount += 1;
206+
return readCount === 1 ? 'camelCase' : '';
207+
}
208+
});
209+
210+
const dto = {
211+
template: '{{<tag>Id}}',
212+
oaOperation: oaOperation,
213+
dynamicValues: {},
214+
options
215+
};
216+
const result = parseTpl(dto);
217+
expect(result).toBe('{{TrainId}}');
218+
});
199219
});
200220

201221
describe('hasTpl', () => {
@@ -223,3 +243,18 @@ describe('hasTpl', () => {
223243
expect(result).toBe(true);
224244
});
225245
});
246+
247+
describe('getOperation', () => {
248+
it('returns undefined when path exists but method does not', () => {
249+
const oa = {
250+
paths: {
251+
'/trains/{id}': {
252+
get: {operationId: 'trainDetails'}
253+
}
254+
}
255+
};
256+
257+
const result = getOperation('/trains/{id}', 'post', oa);
258+
expect(result).toBeUndefined();
259+
});
260+
});

0 commit comments

Comments
 (0)