Skip to content

Commit

Permalink
fix: update tests for strictNullChecks
Browse files Browse the repository at this point in the history
  • Loading branch information
shetzel committed Jan 18, 2023
1 parent 62575bd commit 685b466
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 12 deletions.
3 changes: 1 addition & 2 deletions test/nuts/mpd.nut.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,11 @@ import * as fs from 'fs';
import { TestSession } from '@salesforce/cli-plugins-testkit';
import { expect } from 'chai';
import { Org, SfProject } from '@salesforce/core';
import { getString } from '@salesforce/ts-types';
import { SourceTracking } from '../../src/sourceTracking';

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

Expand Down
16 changes: 10 additions & 6 deletions test/unit/conflicts.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,15 @@ import { ForceIgnore, ComponentSet } from '@salesforce/source-deploy-retrieve';
import { findConflictsInComponentSet, getDedupedConflictsFromChanges } from '../../src/shared/conflicts';
import { ChangeResult } from '../../src/shared/types';

const clsFullName = 'MyClass';
const clsType = 'ApexClass';
const file1cls = 'foo/classes/MyClass.cls';
const file1meta = 'foo/classes/MyClass.cls-meta.xml';
const class1Local: ChangeResult = {
origin: 'local',
name: 'MyClass',
type: 'ApexClass',
filenames: ['foo/classes/MyClass.cls', 'foo/classes/MyClass.cls-meta.xml'],
name: clsFullName,
type: clsType,
filenames: [file1cls, file1meta],
};

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

describe('filter component set', () => {
it('matches a conflict in a component set', () => {
const cs = new ComponentSet([{ fullName: class1Local.name, type: class1Local.type }]);
const cs = new ComponentSet([{ fullName: clsFullName, type: clsType }]);
expect(findConflictsInComponentSet(cs, [class1Local])).to.deep.equal([
{
filePath: path.join(__dirname, '..', '..', class1Local.filenames[0]),
filePath: path.join(__dirname, '..', '..', file1cls),
fullName: class1Local.name,
state: 'Conflict',
type: class1Local.type,
},
{
filePath: path.join(__dirname, '..', '..', class1Local.filenames[1]),
filePath: path.join(__dirname, '..', '..', file1meta),
fullName: class1Local.name,
state: 'Conflict',
type: class1Local.type,
Expand Down
10 changes: 7 additions & 3 deletions test/unit/expectedSourceMembers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,13 @@ describe('expectedSourceMembers', () => {
const result = calculateExpectedSourceMembers(input);
expect(result.size).to.equal(1);
// fields return object, field for their keys
expect(result.get(getMetadataKeyFromFileResponse(input[2]).find((f) => f.startsWith('CustomField')))).to.deep.equal(
input[2]
);
const input2 = getMetadataKeyFromFileResponse(input[2]);
const mdKey = input2.find((f) => f.startsWith('CustomField'));
if (mdKey) {
expect(result.get(mdKey)).to.deep.equal(input[2]);
} else {
expect(false, 'CustomField metadata not found');
}
});

it('omits aura xml types', () => {
Expand Down
2 changes: 1 addition & 1 deletion test/unit/localShadowRepo.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ afterEach(() => {

describe('localShadowRepo', () => {
it('does not add same file multiple times', async () => {
let projectDir: string;
let projectDir!: string;
try {
projectDir = fs.mkdtempSync(path.join(os.tmpdir(), 'localShadowRepoTest'));
fs.mkdirSync(path.join(projectDir, 'force-app'));
Expand Down
2 changes: 2 additions & 0 deletions test/unit/remoteSourceTracking.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,9 @@ describe('remoteSourceTrackingService', () => {
describe('init', () => {
it('should set initial state of contents', async () => {
$$.SANDBOX.stub(remoteSourceTrackingService, 'getContents').returns({
// @ts-ignore
serverMaxRevisionCounter: null,
// @ts-ignore
sourceMembers: null,
}) as SinonStub;
// @ts-ignore
Expand Down

0 comments on commit 685b466

Please sign in to comment.