|
| 1 | +/* |
| 2 | + * Copyright (c) 2018, salesforce.com, inc. |
| 3 | + * All rights reserved. |
| 4 | + * Licensed under the BSD 3-Clause license. |
| 5 | + * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause |
| 6 | + */ |
| 7 | + |
| 8 | +import { fs } from '@salesforce/core'; |
| 9 | +import { expect } from 'chai'; |
| 10 | +import { readFileSync } from 'fs'; |
| 11 | +import { join } from 'path'; |
| 12 | + |
| 13 | +/** |
| 14 | + * This plugin was primarily made to generate command reference docs for |
| 15 | + * salesforcedx. Generate actual docs and ensure some of the files are generated |
| 16 | + * correctly. If there is new code added to fix a new bug that relies on a new |
| 17 | + * version of salesforcedx, updated it in the package.json. To add test for other |
| 18 | + * plugins, it would probably be best to create a base test to generate the docs |
| 19 | + * for the test cases to reference. |
| 20 | + */ |
| 21 | + |
| 22 | +const testFilesPath = './test/tmp'; |
| 23 | + |
| 24 | +function loadTestDitamapFile(path: string) { |
| 25 | + return readFileSync(join(testFilesPath, path), 'utf8'); |
| 26 | +} |
| 27 | + |
| 28 | +describe('salesforcedx', () => { |
| 29 | + before(async () => { |
| 30 | + await require('@oclif/command').run([ |
| 31 | + 'commandreference:generate', |
| 32 | + '--plugins', |
| 33 | + 'salesforcedx', |
| 34 | + '--outputdir', |
| 35 | + testFilesPath |
| 36 | + ]); |
| 37 | + }); |
| 38 | + after(async () => { |
| 39 | + await fs.remove(testFilesPath); |
| 40 | + }); |
| 41 | + |
| 42 | + it('creates closed-pilot commands', async () => { |
| 43 | + const dita = loadTestDitamapFile(join('force', 'org', 'cli_reference_force_org_shape_create.xml')); |
| 44 | + expect(/invitation-only\s+pilot\s+program/.test(dita)).to.be.true; |
| 45 | + }); |
| 46 | + it('creates beta commands', async () => { |
| 47 | + const dita = loadTestDitamapFile(join('force', 'org', 'cli_reference_force_org_clone.xml')); |
| 48 | + expect(/a\s+beta\s+version\s+of\s+the/.test(dita)).to.be.true; |
| 49 | + }); |
| 50 | + it('creates open-pilot commands', async () => { |
| 51 | + const dita = loadTestDitamapFile(join('force', 'package', 'cli_reference_force_package_hammertest_run.xml')); |
| 52 | + expect(/through\s+a\s+pilot\s+program\s+that\s+requires/.test(dita)).to.be.true; |
| 53 | + }); |
| 54 | + it('creates with long description', async () => { |
| 55 | + const dita = loadTestDitamapFile(join('force', 'source', 'cli_reference_force_source_push.xml')); |
| 56 | + expect(/shortdesc">Pushes changed/.test(dita)).to.be.true; |
| 57 | + }); |
| 58 | +}); |
0 commit comments