-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathendtoend.test.ts
More file actions
66 lines (61 loc) · 2.59 KB
/
endtoend.test.ts
File metadata and controls
66 lines (61 loc) · 2.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/*
* Copyright 2026, Salesforce, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { access, rm } from 'node:fs/promises';
import { readFileSync } from 'node:fs';
import { join } from 'node:path';
import { expect } from 'chai';
/**
* This plugin was primarily made to generate command reference docs for
* salesforcedx. Generate actual docs and ensure some of the files are generated
* correctly. If there is new code added to fix a new bug that relies on a new
* version of salesforcedx, updated it in the package.json. To add test for other
* plugins, it would probably be best to create a base test to generate the docs
* for the test cases to reference.
*/
const testFilesPath = './test/tmp';
function loadTestDitamapFile(path: string) {
return readFileSync(join(testFilesPath, path), 'utf8');
}
describe('plugin-auth and user', () => {
before(async () => {
try {
await access(testFilesPath);
} catch (e) {
throw new Error(
`Could not read generated test docs from ${testFilesPath}. Ensure the "pretest" has run or run it manually.`
);
}
});
after(async () => {
await rm(testFilesPath, { recursive: true });
});
it('produces no [object Object] nonsense for default flags', () => {
const dita = loadTestDitamapFile(join('org', 'cli_reference_org_create_user_unified.xml'));
expect(dita.includes('[object Object]')).to.be.false;
});
it('creates with spaced commands', async () => {
const dita = loadTestDitamapFile(join('org', 'cli_reference_org_login_jwt_unified.xml'));
expect(dita.includes('<title><codeph otherprops="nolang">org login jwt')).to.be.true;
});
it('creates with summary', async () => {
const dita = loadTestDitamapFile(join('org', 'cli_reference_org_login_jwt_unified.xml'));
expect(/shortdesc">\r?\n(\s.*)Log in to a Salesforce org using a JSON web token \(JWT\)./.test(dita)).to.be.true;
});
it('creates parameters', async () => {
const dita = loadTestDitamapFile(join('org', 'cli_reference_org_login_jwt_unified.xml'));
expect(dita.includes('title><ph>Flags</ph></title>')).to.be.true;
});
});