|
| 1 | +import { expect } from 'chai'; |
| 2 | +import sinon from 'sinon'; |
| 3 | +import ExportCommand from '../../../../../src/commands/cm/stacks/export'; |
| 4 | + |
| 5 | +describe('ExportCommand', () => { |
| 6 | + afterEach(() => { |
| 7 | + sinon.restore(); |
| 8 | + }); |
| 9 | + |
| 10 | + describe('Flags Configuration', () => { |
| 11 | + it('should have all required flags defined', () => { |
| 12 | + const flags = ExportCommand.flags; |
| 13 | + |
| 14 | + expect(flags).to.have.property('stack-api-key'); |
| 15 | + expect(flags).to.have.property('data-dir'); |
| 16 | + expect(flags).to.have.property('alias'); |
| 17 | + expect(flags).to.have.property('config'); |
| 18 | + expect(flags).to.have.property('module'); |
| 19 | + expect(flags).to.have.property('branch'); |
| 20 | + expect(flags).to.have.property('branch-alias'); |
| 21 | + expect(flags).to.have.property('secured-assets'); |
| 22 | + }); |
| 23 | + |
| 24 | + it('should have correct exclusive flags for branch', () => { |
| 25 | + const flags = ExportCommand.flags; |
| 26 | + |
| 27 | + expect(flags['branch']).to.have.property('exclusive'); |
| 28 | + expect(flags['branch-alias']).to.have.property('exclusive'); |
| 29 | + expect((flags['branch'] as any).exclusive).to.include('branch-alias'); |
| 30 | + expect((flags['branch-alias'] as any).exclusive).to.include('branch'); |
| 31 | + }); |
| 32 | + }); |
| 33 | + |
| 34 | + describe('module flag options', () => { |
| 35 | + it('should have options defined on the module flag', () => { |
| 36 | + const flags = ExportCommand.flags; |
| 37 | + |
| 38 | + expect(flags['module']).to.have.property('options'); |
| 39 | + expect((flags['module'] as any).options).to.be.an('array').that.is.not.empty; |
| 40 | + }); |
| 41 | + |
| 42 | + it('should accept all valid module names', () => { |
| 43 | + const validModules = [ |
| 44 | + 'stack', |
| 45 | + 'assets', |
| 46 | + 'locales', |
| 47 | + 'environments', |
| 48 | + 'extensions', |
| 49 | + 'webhooks', |
| 50 | + 'global-fields', |
| 51 | + 'entries', |
| 52 | + 'content-types', |
| 53 | + 'custom-roles', |
| 54 | + 'workflows', |
| 55 | + 'labels', |
| 56 | + 'marketplace-apps', |
| 57 | + 'taxonomies', |
| 58 | + 'personalize', |
| 59 | + 'composable-studio', |
| 60 | + ]; |
| 61 | + const moduleOptions = (ExportCommand.flags['module'] as any).options as string[]; |
| 62 | + |
| 63 | + for (const mod of validModules) { |
| 64 | + expect(moduleOptions).to.include(mod, `module flag options should include '${mod}'`); |
| 65 | + } |
| 66 | + }); |
| 67 | + |
| 68 | + it('should not accept invalid module names', () => { |
| 69 | + const moduleOptions = (ExportCommand.flags['module'] as any).options as string[]; |
| 70 | + |
| 71 | + expect(moduleOptions).to.not.include('invalid-module'); |
| 72 | + expect(moduleOptions).to.not.include('foo'); |
| 73 | + expect(moduleOptions).to.not.include(''); |
| 74 | + }); |
| 75 | + |
| 76 | + it('should have the correct number of valid modules', () => { |
| 77 | + const moduleOptions = (ExportCommand.flags['module'] as any).options as string[]; |
| 78 | + |
| 79 | + expect(moduleOptions).to.have.lengthOf(16); |
| 80 | + }); |
| 81 | + }); |
| 82 | +}); |
0 commit comments