Skip to content

Commit 8e8b966

Browse files
committed
fix: tests
1 parent 0da3437 commit 8e8b966

File tree

2 files changed

+33
-20
lines changed

2 files changed

+33
-20
lines changed

packages/create-app/src/lib/__tests__/bin.test.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ test('should format config without plugins', () => {
1515
ios: platformIOS(),
1616
android: platformAndroid(),
1717
},
18-
remoteCacheProvider: null,
1918
};
2019
"
2120
`);
@@ -33,11 +32,16 @@ test('should format config with plugins', () => {
3332
},
3433
];
3534

36-
expect(formatConfig([PLATFORMS[0]], plugins, BUNDLERS[1], 'github-actions'))
37-
.toMatchInlineSnapshot(`
35+
expect(
36+
formatConfig([PLATFORMS[0]], plugins, BUNDLERS[1], {
37+
name: 'github-actions',
38+
args: { owner: 'custom-owner', repo: 'repo-name', token: 'GITHUB_TOKEN' },
39+
}),
40+
).toMatchInlineSnapshot(`
3841
"import { platformIOS } from '@rock-js/platform-ios';
3942
import { pluginTest } from '@rock-js/plugin-test';
4043
import { pluginRepack } from '@rock-js/plugin-repack';
44+
import { providerGithubActions } from '@rock-js/provider-github-actions';
4145
4246
export default {
4347
plugins: [
@@ -47,7 +51,11 @@ test('should format config with plugins', () => {
4751
platforms: {
4852
ios: platformIOS(),
4953
},
50-
remoteCacheProvider: 'github-actions',
54+
remoteCacheProvider: providerGithubActions({
55+
owner: "custom-owner",
56+
repo: "repo-name",
57+
token: process.env['GITHUB_TOKEN'],
58+
}),
5159
};
5260
"
5361
`);

packages/create-app/src/lib/bin.ts

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -332,38 +332,43 @@ export function formatConfig(
332332
const pluginsWithImports = plugins
333333
? plugins.filter((template) => template.importName)
334334
: null;
335-
return `${[...platformsWithImports, ...(pluginsWithImports ?? []), bundler]
336-
.map(
335+
336+
return `${[
337+
...[...platformsWithImports, ...(pluginsWithImports ?? []), bundler].map(
337338
(template) =>
338339
`import { ${template.importName} } from '${template.packageName}';`,
339-
)
340+
),
341+
remoteCacheProvider?.name
342+
? remoteCacheProviderToImportTemplate(remoteCacheProvider.name)
343+
: '',
344+
]
345+
.filter(Boolean)
340346
.join('\n')}
341-
${[remoteCacheProvider ? remoteCacheProviderToImportTemplate(remoteCacheProvider.name) : '']}
342347
343-
export default {${
348+
export default {
349+
${[
344350
pluginsWithImports && pluginsWithImports.length > 0
345-
? `
346-
plugins: [
351+
? `plugins: [
347352
${pluginsWithImports
348353
.map((template) => `${template.importName}(),`)
349354
.join('\n ')}
350355
],`
351-
: ''
352-
}
353-
bundler: ${bundler.importName}(),
354-
platforms: {
356+
: '',
357+
`bundler: ${bundler.importName}(),`,
358+
`platforms: {
355359
${platformsWithImports
356360
.map((template) => `${template.name}: ${template.importName}(),`)
357361
.join('\n ')}
358-
},
359-
${
360-
remoteCacheProvider
362+
},`,
363+
remoteCacheProvider?.name
361364
? remoteCacheProviderToConfigTemplate(
362365
remoteCacheProvider.name,
363366
remoteCacheProvider.args,
364367
)
365-
: ''
366-
}
368+
: '',
369+
]
370+
.filter(Boolean)
371+
.join('\n ')}
367372
};
368373
`;
369374
}

0 commit comments

Comments
 (0)