diff --git a/src/lifter.js b/src/lifter.js index 8b16857..a7dbf97 100644 --- a/src/lifter.js +++ b/src/lifter.js @@ -8,7 +8,7 @@ export default async function ({projectRoot, results: {projectDetails: {homepage config: { repository: { homepage, - topics: tags.join(', ') + ...tags && {topics: tags.join(', ')} } } }); diff --git a/src/lifter.test.js b/src/lifter.test.js index a7965c8..b0ff7b7 100644 --- a/src/lifter.test.js +++ b/src/lifter.test.js @@ -10,10 +10,9 @@ vi.mock('@form8ion/core'); describe('lifter', () => { const projectRoot = any.simpleObject(); const tags = any.listOf(any.word); + const homepage = any.url(); it('should set properties in the settings file', async () => { - const homepage = any.url(); - const result = await lift({ projectRoot, results: { @@ -55,4 +54,24 @@ describe('lifter', () => { } }); }); + + it('should not result in an error when tags are not provided in the results', async () => { + await lift({ + projectRoot, + results: { + projectDetails: {homepage} + } + }); + + expect(mergeIntoExistingConfigFile).toHaveBeenCalledWith({ + format: fileTypes.YAML, + path: `${projectRoot}/.github`, + name: 'settings', + config: { + repository: { + homepage + } + } + }); + }); }); diff --git a/test/integration/features/lift.feature b/test/integration/features/lift.feature index 0e4c5d7..425e08b 100644 --- a/test/integration/features/lift.feature +++ b/test/integration/features/lift.feature @@ -3,12 +3,21 @@ Feature: Lift Scenario: Lift Given the GitHub repository settings are managed by the repository-settings app And the scaffolder results include projectDetails + And the scaffolder results include tags When scaffolder results are processed Then properties are updated in the settings file Scenario: Lift w/o project details Given the GitHub repository settings are managed by the repository-settings app - And the scaffolder results do not include projectDetails + And the scaffolder results include tags + But the scaffolder results do not include projectDetails + When scaffolder results are processed + Then properties are updated in the settings file + + Scenario: Lift w/o tags + Given the GitHub repository settings are managed by the repository-settings app + And the scaffolder results include projectDetails + But the scaffolder results do not include tags When scaffolder results are processed Then properties are updated in the settings file diff --git a/test/integration/features/step_definitions/common-steps.js b/test/integration/features/step_definitions/common-steps.js index 9e2420c..c70f5de 100644 --- a/test/integration/features/step_definitions/common-steps.js +++ b/test/integration/features/step_definitions/common-steps.js @@ -41,8 +41,6 @@ When('the project is scaffolded', async function () { }); When('scaffolder results are processed', async function () { - this.tags = any.listOf(any.word); - if (await test({projectRoot: this.projectRoot})) { await lift({ projectRoot: this.projectRoot, diff --git a/test/integration/features/step_definitions/results-steps.js b/test/integration/features/step_definitions/results-steps.js index 8cf12dc..2be5999 100644 --- a/test/integration/features/step_definitions/results-steps.js +++ b/test/integration/features/step_definitions/results-steps.js @@ -9,3 +9,11 @@ Given('the scaffolder results include projectDetails', async function () { this.homepage = any.url(); this.projectDetails = {homepage: this.homepage}; }); + +Given('the scaffolder results include tags', async function () { + this.tags = any.listOf(any.word); +}); + +Given('the scaffolder results do not include tags', async function () { + return undefined; +}); diff --git a/test/integration/features/step_definitions/settings-steps.js b/test/integration/features/step_definitions/settings-steps.js index ba8a7a3..af39618 100644 --- a/test/integration/features/step_definitions/settings-steps.js +++ b/test/integration/features/step_definitions/settings-steps.js @@ -45,7 +45,7 @@ Then('properties are updated in the settings file', async function () { repository: { ...this.existingSettingsContent.repository, ...this.homepage && {homepage: this.homepage}, - topics: this.tags.join(', ') + ...this.tags && {topics: this.tags.join(', ')} } } );