Skip to content

Commit 685b466

Browse files
committed
fix: update tests for strictNullChecks
1 parent 62575bd commit 685b466

5 files changed

+21
-12
lines changed

test/nuts/mpd.nut.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,11 @@ import * as fs from 'fs';
1010
import { TestSession } from '@salesforce/cli-plugins-testkit';
1111
import { expect } from 'chai';
1212
import { Org, SfProject } from '@salesforce/core';
13-
import { getString } from '@salesforce/ts-types';
1413
import { SourceTracking } from '../../src/sourceTracking';
1514

1615
const getSTLInstance = async (session: TestSession): Promise<SourceTracking> =>
1716
SourceTracking.create({
18-
org: await Org.create({ aliasOrUsername: getString(session, 'setup[0].result.username') }),
17+
org: await Org.create({ aliasOrUsername: session.orgs.get('default')?.username }),
1918
project: await SfProject.resolve(session.project.dir),
2019
});
2120

test/unit/conflicts.test.ts

+10-6
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,15 @@ import { ForceIgnore, ComponentSet } from '@salesforce/source-deploy-retrieve';
1111
import { findConflictsInComponentSet, getDedupedConflictsFromChanges } from '../../src/shared/conflicts';
1212
import { ChangeResult } from '../../src/shared/types';
1313

14+
const clsFullName = 'MyClass';
15+
const clsType = 'ApexClass';
16+
const file1cls = 'foo/classes/MyClass.cls';
17+
const file1meta = 'foo/classes/MyClass.cls-meta.xml';
1418
const class1Local: ChangeResult = {
1519
origin: 'local',
16-
name: 'MyClass',
17-
type: 'ApexClass',
18-
filenames: ['foo/classes/MyClass.cls', 'foo/classes/MyClass.cls-meta.xml'],
20+
name: clsFullName,
21+
type: clsType,
22+
filenames: [file1cls, file1meta],
1923
};
2024

2125
describe('conflicts functions', () => {
@@ -28,16 +32,16 @@ describe('conflicts functions', () => {
2832

2933
describe('filter component set', () => {
3034
it('matches a conflict in a component set', () => {
31-
const cs = new ComponentSet([{ fullName: class1Local.name, type: class1Local.type }]);
35+
const cs = new ComponentSet([{ fullName: clsFullName, type: clsType }]);
3236
expect(findConflictsInComponentSet(cs, [class1Local])).to.deep.equal([
3337
{
34-
filePath: path.join(__dirname, '..', '..', class1Local.filenames[0]),
38+
filePath: path.join(__dirname, '..', '..', file1cls),
3539
fullName: class1Local.name,
3640
state: 'Conflict',
3741
type: class1Local.type,
3842
},
3943
{
40-
filePath: path.join(__dirname, '..', '..', class1Local.filenames[1]),
44+
filePath: path.join(__dirname, '..', '..', file1meta),
4145
fullName: class1Local.name,
4246
state: 'Conflict',
4347
type: class1Local.type,

test/unit/expectedSourceMembers.test.ts

+7-3
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,13 @@ describe('expectedSourceMembers', () => {
3434
const result = calculateExpectedSourceMembers(input);
3535
expect(result.size).to.equal(1);
3636
// fields return object, field for their keys
37-
expect(result.get(getMetadataKeyFromFileResponse(input[2]).find((f) => f.startsWith('CustomField')))).to.deep.equal(
38-
input[2]
39-
);
37+
const input2 = getMetadataKeyFromFileResponse(input[2]);
38+
const mdKey = input2.find((f) => f.startsWith('CustomField'));
39+
if (mdKey) {
40+
expect(result.get(mdKey)).to.deep.equal(input[2]);
41+
} else {
42+
expect(false, 'CustomField metadata not found');
43+
}
4044
});
4145

4246
it('omits aura xml types', () => {

test/unit/localShadowRepo.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ afterEach(() => {
2121

2222
describe('localShadowRepo', () => {
2323
it('does not add same file multiple times', async () => {
24-
let projectDir: string;
24+
let projectDir!: string;
2525
try {
2626
projectDir = fs.mkdtempSync(path.join(os.tmpdir(), 'localShadowRepoTest'));
2727
fs.mkdirSync(path.join(projectDir, 'force-app'));

test/unit/remoteSourceTracking.test.ts

+2
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,9 @@ describe('remoteSourceTrackingService', () => {
7777
describe('init', () => {
7878
it('should set initial state of contents', async () => {
7979
$$.SANDBOX.stub(remoteSourceTrackingService, 'getContents').returns({
80+
// @ts-ignore
8081
serverMaxRevisionCounter: null,
82+
// @ts-ignore
8183
sourceMembers: null,
8284
}) as SinonStub;
8385
// @ts-ignore

0 commit comments

Comments
 (0)