Skip to content

Commit 88a7e45

Browse files
committed
UTs
1 parent 955ecbd commit 88a7e45

File tree

9 files changed

+190
-152
lines changed

9 files changed

+190
-152
lines changed

examples/vitepress/docs/custom-objects/Product_Inline_Fields__c.md

Lines changed: 1 addition & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -20,93 +20,4 @@ The date the product got discontinued
2020

2121
**Type**
2222

23-
*DateTime*
24-
25-
---
26-
### ID
27-
28-
**API Name**
29-
30-
`apexdocs__ID__c`
31-
32-
**Type**
33-
34-
*Number*
35-
36-
---
37-
### Name
38-
39-
Product name
40-
41-
**API Name**
42-
43-
`apexdocs__Name__c`
44-
45-
**Type**
46-
47-
*Text*
48-
49-
---
50-
### Price
51-
52-
Product price in the default currency
53-
54-
**API Name**
55-
56-
`apexdocs__Price__c`
57-
58-
**Type**
59-
60-
*Number*
61-
62-
---
63-
### Products
64-
65-
**API Name**
66-
67-
`apexdocs__Products__c`
68-
69-
**Type**
70-
71-
*ExternalLookup*
72-
73-
---
74-
### Rating
75-
76-
Rating
77-
78-
**API Name**
79-
80-
`apexdocs__Rating__c`
81-
82-
**Type**
83-
84-
*Number*
85-
86-
---
87-
### ReleaseDate
88-
89-
ReleaseDate
90-
91-
**API Name**
92-
93-
`apexdocs__ReleaseDate__c`
94-
95-
**Type**
96-
97-
*DateTime*
98-
99-
---
100-
### Type
101-
102-
**API Name**
103-
104-
`apexdocs__Type__c`
105-
106-
**Type**
107-
108-
*Picklist*
109-
110-
#### Possible values are
111-
* Merchandise
112-
* Bundle
23+
*DateTime*

src/core/changelog/__test__/generating-change-log.spec.ts

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ import { UnparsedApexBundle, UnparsedCustomObjectBundle, UnparsedSourceBundle }
22
import { ChangeLogPageData, generateChangeLog } from '../generate-change-log';
33
import { assertEither } from '../../test-helpers/assert-either';
44
import { isSkip } from '../../shared/utils';
5-
import { customObjectGenerator, unparsedFieldBundleFromRawString } from '../../test-helpers/test-data-builders';
5+
import { unparsedFieldBundleFromRawString } from '../../test-helpers/test-data-builders';
6+
import { CustomObjectXmlBuilder } from '../../test-helpers/test-data-builders/custom-object-xml-builder';
67

78
const config = {
89
fileName: 'changelog',
@@ -186,7 +187,7 @@ describe('when generating a changelog', () => {
186187

187188
describe('that include new custom objects', () => {
188189
it('should include a section for new custom objects', async () => {
189-
const newObjectSource = customObjectGenerator();
190+
const newObjectSource = new CustomObjectXmlBuilder().build();
190191

191192
const oldBundle: UnparsedCustomObjectBundle[] = [];
192193
const newBundle: UnparsedCustomObjectBundle[] = [
@@ -244,7 +245,7 @@ describe('when generating a changelog', () => {
244245

245246
describe('that includes removed custom objects', () => {
246247
it('should include a section for removed custom objects', async () => {
247-
const oldObjectSource = customObjectGenerator();
248+
const oldObjectSource = new CustomObjectXmlBuilder().build();
248249

249250
const oldBundle: UnparsedCustomObjectBundle[] = [
250251
{ type: 'customobject', name: 'MyTestObject', content: oldObjectSource, filePath: 'MyTestObject.object' },
@@ -259,7 +260,7 @@ describe('when generating a changelog', () => {
259260
});
260261

261262
it('should include the removed custom object name', async () => {
262-
const oldObjectSource = customObjectGenerator();
263+
const oldObjectSource = new CustomObjectXmlBuilder().build();
263264

264265
const oldBundle: UnparsedCustomObjectBundle[] = [
265266
{ type: 'customobject', name: 'MyTestObject', content: oldObjectSource, filePath: 'MyTestObject.object' },
@@ -329,8 +330,8 @@ describe('when generating a changelog', () => {
329330

330331
describe('that includes modifications to custom fields', () => {
331332
it('should include a section for new or removed custom fields', async () => {
332-
const oldObjectSource = customObjectGenerator();
333-
const newObjectSource = customObjectGenerator();
333+
const oldObjectSource = new CustomObjectXmlBuilder().build();
334+
const newObjectSource = new CustomObjectXmlBuilder().build();
334335

335336
const oldBundle: UnparsedSourceBundle[] = [
336337
{ type: 'customobject', name: 'MyTestObject', content: oldObjectSource, filePath: 'MyTestObject.object' },
@@ -351,8 +352,8 @@ describe('when generating a changelog', () => {
351352
});
352353

353354
it('should include new custom field names', async () => {
354-
const oldObjectSource = customObjectGenerator();
355-
const newObjectSource = customObjectGenerator();
355+
const oldObjectSource = new CustomObjectXmlBuilder().build();
356+
const newObjectSource = new CustomObjectXmlBuilder().build();
356357

357358
const oldBundle: UnparsedSourceBundle[] = [
358359
{ type: 'customobject', name: 'MyTestObject', content: oldObjectSource, filePath: 'MyTestObject.object' },
@@ -371,8 +372,8 @@ describe('when generating a changelog', () => {
371372
});
372373

373374
it('should include removed custom field names', async () => {
374-
const oldObjectSource = customObjectGenerator();
375-
const newObjectSource = customObjectGenerator();
375+
const oldObjectSource = new CustomObjectXmlBuilder().build();
376+
const newObjectSource = new CustomObjectXmlBuilder().build();
376377

377378
const oldBundle: UnparsedSourceBundle[] = [
378379
{ type: 'customobject', name: 'MyTestObject', content: oldObjectSource, filePath: 'MyTestObject.object' },

src/core/markdown/__test__/generating-custom-object-docs.spec.ts

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import { extendExpect } from './expect-extensions';
22
import { customFieldPickListValues, generateDocs, unparsedObjectBundleFromRawString } from './test-helpers';
33
import { assertEither } from '../../test-helpers/assert-either';
4-
import { customObjectGenerator, unparsedFieldBundleFromRawString } from '../../test-helpers/test-data-builders';
4+
import { unparsedFieldBundleFromRawString } from '../../test-helpers/test-data-builders';
5+
import { CustomObjectXmlBuilder } from '../../test-helpers/test-data-builders/custom-object-xml-builder';
56

67
describe('Generates Custom Object documentation', () => {
78
beforeAll(() => {
@@ -11,7 +12,7 @@ describe('Generates Custom Object documentation', () => {
1112
describe('documentation content', () => {
1213
it('displays the object label as a heading', async () => {
1314
const input = unparsedObjectBundleFromRawString({
14-
rawContent: customObjectGenerator(),
15+
rawContent: new CustomObjectXmlBuilder().build(),
1516
filePath: 'src/object/TestObject__c.object-meta.xml',
1617
});
1718

@@ -22,7 +23,7 @@ describe('Generates Custom Object documentation', () => {
2223

2324
it('displays the object description', async () => {
2425
const input = unparsedObjectBundleFromRawString({
25-
rawContent: customObjectGenerator(),
26+
rawContent: new CustomObjectXmlBuilder().build(),
2627
filePath: 'src/object/TestObject__c.object-meta.xml',
2728
});
2829

@@ -33,7 +34,7 @@ describe('Generates Custom Object documentation', () => {
3334

3435
it('displays the object api name', async () => {
3536
const input = unparsedObjectBundleFromRawString({
36-
rawContent: customObjectGenerator(),
37+
rawContent: new CustomObjectXmlBuilder().build(),
3738
filePath: 'src/object/TestObject__c.object-meta.xml',
3839
});
3940

@@ -44,7 +45,7 @@ describe('Generates Custom Object documentation', () => {
4445

4546
it('displays the Fields heading if fields are present', async () => {
4647
const customObjectBundle = unparsedObjectBundleFromRawString({
47-
rawContent: customObjectGenerator(),
48+
rawContent: new CustomObjectXmlBuilder().build(),
4849
filePath: 'src/object/TestObject__c.object-meta.xml',
4950
});
5051

@@ -60,7 +61,7 @@ describe('Generates Custom Object documentation', () => {
6061

6162
it('displays the pick list values name', async () => {
6263
const customObjectBundle = unparsedObjectBundleFromRawString({
63-
rawContent: customObjectGenerator(),
64+
rawContent: new CustomObjectXmlBuilder().build(),
6465
filePath: 'src/object/TestObject__c.object-meta.xml',
6566
});
6667

@@ -79,7 +80,7 @@ describe('Generates Custom Object documentation', () => {
7980

8081
it('does not display the Fields heading if no fields are present', async () => {
8182
const input = unparsedObjectBundleFromRawString({
82-
rawContent: customObjectGenerator(),
83+
rawContent: new CustomObjectXmlBuilder().build(),
8384
filePath: 'src/object/TestObject__c.object-meta.xml',
8485
});
8586

@@ -90,7 +91,7 @@ describe('Generates Custom Object documentation', () => {
9091

9192
it('displays the field label as a heading', async () => {
9293
const customObjectBundle = unparsedObjectBundleFromRawString({
93-
rawContent: customObjectGenerator(),
94+
rawContent: new CustomObjectXmlBuilder().build(),
9495
filePath: 'src/object/TestObject__c.object-meta.xml',
9596
});
9697

@@ -106,7 +107,7 @@ describe('Generates Custom Object documentation', () => {
106107

107108
it('displays the field description', async () => {
108109
const customObjectBundle = unparsedObjectBundleFromRawString({
109-
rawContent: customObjectGenerator(),
110+
rawContent: new CustomObjectXmlBuilder().build(),
110111
filePath: 'src/object/TestObject__c.object-meta.xml',
111112
});
112113

@@ -122,7 +123,7 @@ describe('Generates Custom Object documentation', () => {
122123

123124
it('displays the field api name', async () => {
124125
const customObjectBundle = unparsedObjectBundleFromRawString({
125-
rawContent: customObjectGenerator(),
126+
rawContent: new CustomObjectXmlBuilder().build(),
126127
filePath: 'src/object/TestObject__c.object-meta.xml',
127128
});
128129

src/core/markdown/__test__/generating-docs.spec.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { DocPageData, PostHookDocumentationBundle } from '../../shared/types';
22
import { extendExpect } from './expect-extensions';
33
import { unparsedApexBundleFromRawString, generateDocs, unparsedObjectBundleFromRawString } from './test-helpers';
44
import { assertEither } from '../../test-helpers/assert-either';
5-
import { customObjectGenerator } from '../../test-helpers/test-data-builders';
5+
import { CustomObjectXmlBuilder } from '../../test-helpers/test-data-builders/custom-object-xml-builder';
66

77
function aSingleDoc(result: PostHookDocumentationBundle): DocPageData {
88
expect(result.docs).toHaveLength(1);
@@ -51,14 +51,14 @@ describe('When generating documentation', () => {
5151
][] = [
5252
[
5353
{
54-
rawContent: customObjectGenerator(),
54+
rawContent: new CustomObjectXmlBuilder().build(),
5555
filePath: 'src/object/MyFirstObject__c.object-meta.xml',
5656
},
5757
'custom-objects',
5858
],
5959
[
6060
{
61-
rawContent: customObjectGenerator(),
61+
rawContent: new CustomObjectXmlBuilder().build(),
6262
filePath: 'src/object/MySecondObject__c.object-meta.xml',
6363
},
6464
'custom-objects',
@@ -127,7 +127,7 @@ describe('When generating documentation', () => {
127127
][] = [
128128
[
129129
{
130-
rawContent: customObjectGenerator(),
130+
rawContent: new CustomObjectXmlBuilder().build(),
131131
filePath: 'src/object/MyFirstObject__c.object-meta.xml',
132132
},
133133
'customobject',
@@ -154,14 +154,14 @@ describe('When generating documentation', () => {
154154
});
155155

156156
it('does not return non-deployed custom objects', async () => {
157-
const input = customObjectGenerator({ deploymentStatus: 'InDevelopment', visibility: 'Public' });
157+
const input = new CustomObjectXmlBuilder().withDeploymentStatus('InDevelopment').build();
158158

159159
const result = await generateDocs([unparsedObjectBundleFromRawString({ rawContent: input, filePath: 'test' })])();
160160
expect(result).documentationBundleHasLength(0);
161161
});
162162

163163
it('does not return non-public custom objects', async () => {
164-
const input = customObjectGenerator({ deploymentStatus: 'Deployed', visibility: 'Protected' });
164+
const input = new CustomObjectXmlBuilder().withVisibility('Protected').build();
165165

166166
const result = await generateDocs([unparsedObjectBundleFromRawString({ rawContent: input, filePath: 'test' })])();
167167
expect(result).documentationBundleHasLength(0);
@@ -196,7 +196,7 @@ describe('When generating documentation', () => {
196196
});
197197

198198
it('includes a heading with the Custom Object label', async () => {
199-
const input = customObjectGenerator();
199+
const input = new CustomObjectXmlBuilder().build();
200200

201201
const result = await generateDocs([unparsedObjectBundleFromRawString({ rawContent: input, filePath: 'test' })])();
202202
expect(result).documentationBundleHasLength(1);

src/core/markdown/__test__/generating-reference-guide.spec.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import * as E from 'fp-ts/Either';
44
import { unparsedApexBundleFromRawString, generateDocs, unparsedObjectBundleFromRawString } from './test-helpers';
55
import { ReferenceGuidePageData } from '../../shared/types';
66
import { assertEither } from '../../test-helpers/assert-either';
7-
import { customObjectGenerator } from '../../test-helpers/test-data-builders';
7+
import { CustomObjectXmlBuilder } from '../../test-helpers/test-data-builders/custom-object-xml-builder';
88

99
describe('When generating the Reference Guide', () => {
1010
beforeAll(() => {
@@ -40,7 +40,7 @@ describe('When generating the Reference Guide', () => {
4040
`;
4141

4242
const input3 = {
43-
rawContent: customObjectGenerator(),
43+
rawContent: new CustomObjectXmlBuilder().build(),
4444
filePath: 'src/object/TestObject__c.object-meta.xml',
4545
};
4646

@@ -99,7 +99,7 @@ describe('When generating the Reference Guide', () => {
9999

100100
it('group SObjects under the Custom Objects group by default', async () => {
101101
const input = {
102-
rawContent: customObjectGenerator(),
102+
rawContent: new CustomObjectXmlBuilder().build(),
103103
filePath: 'src/object/TestObject__c.object-meta.xml',
104104
};
105105

@@ -112,7 +112,7 @@ describe('When generating the Reference Guide', () => {
112112

113113
it('groups SObjects under the provided group', async () => {
114114
const input = {
115-
rawContent: customObjectGenerator(),
115+
rawContent: new CustomObjectXmlBuilder().build(),
116116
filePath: 'src/object/TestObject__c.object-meta.xml',
117117
};
118118

@@ -180,7 +180,7 @@ describe('When generating the Reference Guide', () => {
180180
`;
181181

182182
const input3 = {
183-
rawContent: customObjectGenerator(),
183+
rawContent: new CustomObjectXmlBuilder().build(),
184184
filePath: 'src/object/TestObject__c.object-meta.xml',
185185
};
186186

@@ -222,7 +222,7 @@ describe('When generating the Reference Guide', () => {
222222
`;
223223

224224
const input3 = {
225-
rawContent: customObjectGenerator(),
225+
rawContent: new CustomObjectXmlBuilder().build(),
226226
filePath: 'src/object/ATestObject__c.object-meta.xml',
227227
};
228228

0 commit comments

Comments
 (0)