Skip to content

Commit 2235342

Browse files
committed
chore: Code formatting
1 parent a184a1f commit 2235342

2 files changed

Lines changed: 11 additions & 38 deletions

File tree

test/overlay.test.js

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -225,10 +225,7 @@ describe('openapi-format CLI overlay tests', () => {
225225
};
226226

227227
const result = await openapiOverlay(baseOAS, {overlaySet});
228-
expect(result.data.servers).toEqual([
229-
{url: 'https://api.example.com'},
230-
{url: 'https://api.backup.example.com'}
231-
]);
228+
expect(result.data.servers).toEqual([{url: 'https://api.example.com'}, {url: 'https://api.backup.example.com'}]);
232229
});
233230

234231
it('should spread update arrays into array targets', async () => {
@@ -306,10 +303,7 @@ describe('openapi-format CLI overlay tests', () => {
306303
};
307304

308305
const result = await openapiOverlay(baseOAS, {overlaySet});
309-
expect(result.data.servers).toEqual([
310-
{url: 'https://api.example.com'},
311-
{url: 'https://api.backup.example.com'}
312-
]);
306+
expect(result.data.servers).toEqual([{url: 'https://api.example.com'}, {url: 'https://api.backup.example.com'}]);
313307
});
314308

315309
it('should spread copied arrays into array targets', async () => {
@@ -354,9 +348,7 @@ describe('openapi-format CLI overlay tests', () => {
354348
const result = await openapiOverlay(baseOAS, {overlaySet});
355349
expect(result.resultData.totalUsedActions).toBe(0);
356350
expect(result.resultData.totalUnusedActions).toBe(1);
357-
expect(consoleSpy).toHaveBeenCalledWith(
358-
'Overlay action #1: "from" must resolve to exactly one node, resolved 0.'
359-
);
351+
expect(consoleSpy).toHaveBeenCalledWith('Overlay action #1: "from" must resolve to exactly one node, resolved 0.');
360352
consoleSpy.mockRestore();
361353
});
362354

@@ -373,9 +365,7 @@ describe('openapi-format CLI overlay tests', () => {
373365
const result = await openapiOverlay(baseOAS, {overlaySet});
374366
expect(result.resultData.totalUsedActions).toBe(0);
375367
expect(result.resultData.totalUnusedActions).toBe(1);
376-
expect(consoleSpy).toHaveBeenCalledWith(
377-
'Overlay action #1: "from" must resolve to exactly one node, resolved 2.'
378-
);
368+
expect(consoleSpy).toHaveBeenCalledWith('Overlay action #1: "from" must resolve to exactly one node, resolved 2.');
379369
consoleSpy.mockRestore();
380370
});
381371

utils/overlay.js

Lines changed: 7 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@ async function openapiOverlay(oaObj, options) {
1616
let usedActions = []; // Initialize usedActions array
1717

1818
if (!isSupportedOverlayVersion(overlayVersion)) {
19-
console.error(
20-
`Unsupported overlay version "${overlayVersion}". Supported versions are 1.0.x and 1.1.x.`
21-
);
19+
console.error(`Unsupported overlay version "${overlayVersion}". Supported versions are 1.0.x and 1.1.x.`);
2220
return {
2321
data: oaObj,
2422
resultData: {
@@ -172,9 +170,7 @@ function applyUpdateAction({root, target, update, actionLabel}) {
172170
if (isPlainObject(root) && isPlainObject(update)) {
173171
return {root: deepMerge(root, cloneJsonLike(update)), used: true};
174172
}
175-
console.error(
176-
`${actionLabel}: update at target "$" requires both root and update to be JSON objects.`
177-
);
173+
console.error(`${actionLabel}: update at target "$" requires both root and update to be JSON objects.`);
178174
return {root, used: false};
179175
}
180176

@@ -208,9 +204,7 @@ function applyUpdateAction({root, target, update, actionLabel}) {
208204
function applyCopyAction({root, target, from, actionLabel}) {
209205
const fromNodes = resolveJsonPath(root, from);
210206
if (fromNodes.length !== 1) {
211-
console.error(
212-
`${actionLabel}: "from" must resolve to exactly one node, resolved ${fromNodes.length}.`
213-
);
207+
console.error(`${actionLabel}: "from" must resolve to exactly one node, resolved ${fromNodes.length}.`);
214208
return {root, used: false};
215209
}
216210

@@ -220,9 +214,7 @@ function applyCopyAction({root, target, from, actionLabel}) {
220214
if (isPlainObject(root) && isPlainObject(sourceValue)) {
221215
return {root: deepMerge(root, cloneJsonLike(sourceValue)), used: true};
222216
}
223-
console.error(
224-
`${actionLabel}: copy at target "$" requires both root and source to be JSON objects.`
225-
);
217+
console.error(`${actionLabel}: copy at target "$" requires both root and source to be JSON objects.`);
226218
return {root, used: false};
227219
}
228220

@@ -264,9 +256,7 @@ function applyValueByTargetType({targetValue, incomingValue, mode, actionLabel})
264256

265257
if (isPlainObject(targetValue)) {
266258
if (!isPlainObject(incomingValue)) {
267-
console.error(
268-
`${actionLabel}: ${mode} type mismatch - object target requires object value.`
269-
);
259+
console.error(`${actionLabel}: ${mode} type mismatch - object target requires object value.`);
270260
return {ok: false, value: targetValue};
271261
}
272262

@@ -277,9 +267,7 @@ function applyValueByTargetType({targetValue, incomingValue, mode, actionLabel})
277267
}
278268

279269
if (!isPrimitiveLike(incomingValue)) {
280-
console.error(
281-
`${actionLabel}: ${mode} type mismatch - primitive target requires primitive value.`
282-
);
270+
console.error(`${actionLabel}: ${mode} type mismatch - primitive target requires primitive value.`);
283271
return {ok: false, value: targetValue};
284272
}
285273

@@ -294,12 +282,7 @@ function isPlainObject(value) {
294282
}
295283

296284
function isPrimitiveLike(value) {
297-
return (
298-
value === null ||
299-
typeof value === 'string' ||
300-
typeof value === 'number' ||
301-
typeof value === 'boolean'
302-
);
285+
return value === null || typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean';
303286
}
304287

305288
/**

0 commit comments

Comments
 (0)