|
1 | 1 | import { extendExpect } from './expect-extensions'; |
2 | 2 | import { customFieldPickListValues, generateDocs, unparsedObjectBundleFromRawString } from './test-helpers'; |
3 | 3 | import { assertEither } from '../../test-helpers/assert-either'; |
4 | | -import { unparsedFieldBundleFromRawString } from '../../test-helpers/test-data-builders'; |
| 4 | +import { |
| 5 | + unparsedCustomMetadataFromRawString, |
| 6 | + unparsedFieldBundleFromRawString, |
| 7 | +} from '../../test-helpers/test-data-builders'; |
5 | 8 | import { CustomObjectXmlBuilder } from '../../test-helpers/test-data-builders/custom-object-xml-builder'; |
6 | 9 |
|
7 | 10 | describe('Generates Custom Object documentation', () => { |
@@ -136,5 +139,73 @@ describe('Generates Custom Object documentation', () => { |
136 | 139 | expect(result).documentationBundleHasLength(1); |
137 | 140 | assertEither(result, (data) => expect(data).firstDocContains('`TestField__c`')); |
138 | 141 | }); |
| 142 | + |
| 143 | + describe('when documenting Custom Metadata Types', () => { |
| 144 | + it('displays the Records heading if fields are present', async () => { |
| 145 | + const customObjectBundle = unparsedObjectBundleFromRawString({ |
| 146 | + name: 'TestObject__mdt', |
| 147 | + rawContent: new CustomObjectXmlBuilder().build(), |
| 148 | + filePath: 'src/object/TestObject__mdt.object-meta.xml', |
| 149 | + }); |
| 150 | + |
| 151 | + const customMetadataBundle = unparsedCustomMetadataFromRawString({ |
| 152 | + filePath: 'src/customMetadata/TestField__c.field-meta.xml', |
| 153 | + parentName: 'TestObject', |
| 154 | + apiName: 'TestObject.TestField__c', |
| 155 | + }); |
| 156 | + |
| 157 | + const result = await generateDocs([customObjectBundle, customMetadataBundle])(); |
| 158 | + expect(result).documentationBundleHasLength(1); |
| 159 | + assertEither(result, (data) => expect(data).firstDocContains('## Records')); |
| 160 | + }); |
| 161 | + |
| 162 | + it('does not display the Records heading if no records are present', async () => { |
| 163 | + const input = unparsedObjectBundleFromRawString({ |
| 164 | + name: 'TestObject__mdt', |
| 165 | + rawContent: new CustomObjectXmlBuilder().build(), |
| 166 | + filePath: 'src/object/TestObject__c.object-meta.xml', |
| 167 | + }); |
| 168 | + |
| 169 | + const result = await generateDocs([input])(); |
| 170 | + expect(result).documentationBundleHasLength(1); |
| 171 | + assertEither(result, (data) => expect(data).not.firstDocContains('## Records')); |
| 172 | + }); |
| 173 | + |
| 174 | + it('displays the record label as a heading', async () => { |
| 175 | + const customObjectBundle = unparsedObjectBundleFromRawString({ |
| 176 | + name: 'TestObject__mdt', |
| 177 | + rawContent: new CustomObjectXmlBuilder().build(), |
| 178 | + filePath: 'src/object/TestObject__mdt.object-meta.xml', |
| 179 | + }); |
| 180 | + |
| 181 | + const customMetadataBundle = unparsedCustomMetadataFromRawString({ |
| 182 | + filePath: 'src/customMetadata/TestField__c.field-meta.xml', |
| 183 | + parentName: 'TestObject', |
| 184 | + apiName: 'TestObject.TestField__c', |
| 185 | + }); |
| 186 | + |
| 187 | + const result = await generateDocs([customObjectBundle, customMetadataBundle])(); |
| 188 | + expect(result).documentationBundleHasLength(1); |
| 189 | + assertEither(result, (data) => expect(data).firstDocContains('## Test Metadata')); |
| 190 | + }); |
| 191 | + |
| 192 | + it('displays the record api name', async () => { |
| 193 | + const customObjectBundle = unparsedObjectBundleFromRawString({ |
| 194 | + name: 'TestObject__mdt', |
| 195 | + rawContent: new CustomObjectXmlBuilder().build(), |
| 196 | + filePath: 'src/object/TestObject__mdt.object-meta.xml', |
| 197 | + }); |
| 198 | + |
| 199 | + const customMetadataBundle = unparsedCustomMetadataFromRawString({ |
| 200 | + filePath: 'src/customMetadata/TestField__c.field-meta.xml', |
| 201 | + parentName: 'TestObject', |
| 202 | + apiName: 'TestObject.TestField__c', |
| 203 | + }); |
| 204 | + |
| 205 | + const result = await generateDocs([customObjectBundle, customMetadataBundle])(); |
| 206 | + expect(result).documentationBundleHasLength(1); |
| 207 | + assertEither(result, (data) => expect(data).firstDocContains('TestObject.TestField__c')); |
| 208 | + }); |
| 209 | + }); |
139 | 210 | }); |
140 | 211 | }); |
0 commit comments