@contractkit/prettier-plugin 0.9.1 → 0.9.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build$colon$ci.log +6 -6
- package/.turbo/turbo-test$colon$ci.log +9 -9
- package/CHANGELOG.md +19 -0
- package/coverage/clover.xml +274 -230
- package/coverage/coverage-final.json +4 -4
- package/coverage/indent.ts.html +1 -1
- package/coverage/index.html +31 -31
- package/coverage/print-ck.ts.html +21 -21
- package/coverage/print-contract.ts.html +16 -16
- package/coverage/print-operation.ts.html +252 -45
- package/coverage/print-type.ts.html +56 -35
- package/dist/index.js +74 -3
- package/dist/index.js.map +1 -1
- package/dist/print-operation.d.ts.map +1 -1
- package/dist/print-type.d.ts +3 -0
- package/dist/print-type.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/print-operation.ts +70 -1
- package/src/print-type.ts +9 -2
- package/tests/print-ck.test.ts +77 -0
package/tests/print-ck.test.ts
CHANGED
|
@@ -224,6 +224,56 @@ describe('printCk — plugins block', () => {
|
|
|
224
224
|
const out = printCk(ast);
|
|
225
225
|
expect(out).toContain(' bruno: "request-token.yml"');
|
|
226
226
|
});
|
|
227
|
+
|
|
228
|
+
it('prints object plugin value with file:// URL', () => {
|
|
229
|
+
const ast = makeRoot([
|
|
230
|
+
makeRoute('/auth/token', [
|
|
231
|
+
makeOp('post', { plugins: { bruno: { template: 'file://request-token.yml' } } }),
|
|
232
|
+
]),
|
|
233
|
+
]);
|
|
234
|
+
const out = printCk(ast);
|
|
235
|
+
expect(out).toContain(' bruno: {');
|
|
236
|
+
expect(out).toContain(' template: "file://request-token.yml"');
|
|
237
|
+
});
|
|
238
|
+
|
|
239
|
+
it('round-trips object plugin value through parse', () => {
|
|
240
|
+
const src = `operation /auth/token: {
|
|
241
|
+
post: {
|
|
242
|
+
plugins: {
|
|
243
|
+
bruno: {
|
|
244
|
+
template: "file://request-token.yml"
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
`;
|
|
250
|
+
const diag = new DiagnosticCollector();
|
|
251
|
+
const ast = parseCk(src, 'test.ck', diag);
|
|
252
|
+
expect(diag.hasErrors()).toBe(false);
|
|
253
|
+
const out = printCk(ast);
|
|
254
|
+
expect(out).toContain(' bruno: {');
|
|
255
|
+
expect(out).toContain(' template: "file://request-token.yml"');
|
|
256
|
+
});
|
|
257
|
+
|
|
258
|
+
it('prints scalar, array, and nested-object plugin values', () => {
|
|
259
|
+
const ast = makeRoot([
|
|
260
|
+
makeRoute('/x', [
|
|
261
|
+
makeOp('get', {
|
|
262
|
+
plugins: {
|
|
263
|
+
flag: true,
|
|
264
|
+
count: 3,
|
|
265
|
+
tags: ['a', 'b'],
|
|
266
|
+
meta: { nested: { x: 1 } },
|
|
267
|
+
},
|
|
268
|
+
}),
|
|
269
|
+
]),
|
|
270
|
+
]);
|
|
271
|
+
const out = printCk(ast);
|
|
272
|
+
expect(out).toContain('flag: true');
|
|
273
|
+
expect(out).toContain('count: 3');
|
|
274
|
+
expect(out).toContain('tags: [');
|
|
275
|
+
expect(out).toContain('meta: {');
|
|
276
|
+
});
|
|
227
277
|
});
|
|
228
278
|
|
|
229
279
|
// ─── Query / headers with descriptions ───────────────────────────────────────
|
|
@@ -713,3 +763,30 @@ options {
|
|
|
713
763
|
expect(roundTrip(source)).toBe(source);
|
|
714
764
|
});
|
|
715
765
|
});
|
|
766
|
+
|
|
767
|
+
describe('printCk — enum values with spaces (round-trip)', () => {
|
|
768
|
+
function roundTrip(source: string): string {
|
|
769
|
+
const diag = new DiagnosticCollector();
|
|
770
|
+
const ast = parseCk(source, 'test.ck', diag);
|
|
771
|
+
expect(diag.hasErrors()).toBe(false);
|
|
772
|
+
return printCk(ast);
|
|
773
|
+
}
|
|
774
|
+
|
|
775
|
+
it('round-trips enum with bare identifiers unchanged', () => {
|
|
776
|
+
const source = `\
|
|
777
|
+
contract M: {
|
|
778
|
+
status: enum(active, inactive, pending)
|
|
779
|
+
}
|
|
780
|
+
`;
|
|
781
|
+
expect(roundTrip(source)).toBe(source);
|
|
782
|
+
});
|
|
783
|
+
|
|
784
|
+
it('round-trips enum with quoted multi-word values', () => {
|
|
785
|
+
const source = `\
|
|
786
|
+
contract M: {
|
|
787
|
+
entityType: enum("Sole Proprietorship", LLC, "Limited Partnership")
|
|
788
|
+
}
|
|
789
|
+
`;
|
|
790
|
+
expect(roundTrip(source)).toBe(source);
|
|
791
|
+
});
|
|
792
|
+
});
|