Skip to content

Commit fa32f6d

Browse files
committed
Uts
1 parent dc05405 commit fa32f6d

File tree

2 files changed

+86
-0
lines changed

2 files changed

+86
-0
lines changed

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

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { assertEither } from '../../test-helpers/assert-either';
44
import { isSkip } from '../../shared/utils';
55
import { unparsedFieldBundleFromRawString } from '../../test-helpers/test-data-builders';
66
import { CustomObjectXmlBuilder } from '../../test-helpers/test-data-builders/custom-object-xml-builder';
7+
import { CustomFieldXmlBuilder } from '../../test-helpers/test-data-builders/custom-field-xml-builder';
78

89
const config = {
910
fileName: 'changelog',
@@ -395,4 +396,74 @@ describe('when generating a changelog', () => {
395396
);
396397
});
397398
});
399+
400+
describe('that includes extension fields', () => {
401+
it('does not include the fields when they are in both versions', async () => {
402+
const fieldSource = new CustomFieldXmlBuilder().build();
403+
404+
const oldBundle: UnparsedSourceBundle[] = [
405+
{
406+
type: 'customfield',
407+
name: 'PhotoUrl__c',
408+
content: fieldSource,
409+
filePath: 'PhotoUrl__c.field-meta.xml',
410+
parentName: 'MyTestObject',
411+
},
412+
];
413+
const newBundle: UnparsedSourceBundle[] = [
414+
{
415+
type: 'customfield',
416+
name: 'PhotoUrl__c',
417+
content: fieldSource,
418+
filePath: 'PhotoUrl__c.field-meta.xml',
419+
parentName: 'MyTestObject',
420+
},
421+
];
422+
423+
const result = await generateChangeLog(oldBundle, newBundle, config)();
424+
425+
assertEither(result, (data) => expect((data as ChangeLogPageData).content).not.toContain('MyTestObject'));
426+
assertEither(result, (data) => expect((data as ChangeLogPageData).content).not.toContain('PhotoUrl__c'));
427+
});
428+
429+
it('includes added fields when they are not in the old version', async () => {
430+
const fieldSource = new CustomFieldXmlBuilder().build();
431+
432+
const oldBundle: UnparsedSourceBundle[] = [];
433+
const newBundle: UnparsedSourceBundle[] = [
434+
{
435+
type: 'customfield',
436+
name: 'PhotoUrl__c',
437+
content: fieldSource,
438+
filePath: 'PhotoUrl__c.field-meta.xml',
439+
parentName: 'MyTestObject',
440+
},
441+
];
442+
443+
const result = await generateChangeLog(oldBundle, newBundle, config)();
444+
445+
assertEither(result, (data) => expect((data as ChangeLogPageData).content).toContain('MyTestObject'));
446+
assertEither(result, (data) => expect((data as ChangeLogPageData).content).toContain('PhotoUrl__c'));
447+
});
448+
449+
it('includes removed fields when they are not in the new version', async () => {
450+
const fieldSource = new CustomFieldXmlBuilder().build();
451+
452+
const oldBundle: UnparsedSourceBundle[] = [
453+
{
454+
type: 'customfield',
455+
name: 'PhotoUrl__c',
456+
content: fieldSource,
457+
filePath: 'PhotoUrl__c.field-meta.xml',
458+
parentName: 'MyTestObject',
459+
},
460+
];
461+
const newBundle: UnparsedSourceBundle[] = [];
462+
463+
const result = await generateChangeLog(oldBundle, newBundle, config)();
464+
465+
assertEither(result, (data) => expect((data as ChangeLogPageData).content).toContain('MyTestObject'));
466+
assertEither(result, (data) => expect((data as ChangeLogPageData).content).toContain('PhotoUrl__c'));
467+
});
468+
});
398469
});
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
export class CustomFieldXmlBuilder {
2+
build(): string {
3+
return `
4+
<?xml version="1.0" encoding="UTF-8"?>
5+
<CustomField xmlns="http://soap.sforce.com/2006/04/metadata">
6+
<fullName>PhotoUrl__c</fullName>
7+
<externalId>false</externalId>
8+
<label>PhotoUrl</label>
9+
<required>false</required>
10+
<trackFeedHistory>false</trackFeedHistory>
11+
<type>Url</type>
12+
<description>A URL that points to a photo</description>
13+
</CustomField>`;
14+
}
15+
}

0 commit comments

Comments
 (0)