Skip to content
This repository has been archived by the owner on Dec 6, 2024. It is now read-only.

Commit

Permalink
fix tests per comments
Browse files Browse the repository at this point in the history
  • Loading branch information
maghirardelli committed Sep 10, 2021
1 parent b8c4485 commit fa2873f
Showing 1 changed file with 11 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1423,13 +1423,11 @@ describe('EnvironmentSCService', () => {
expect(securityGroupId).toBeUndefined();
});

describe('pollAndSyncSageMakerStatus', () => {
describe('pollAndSyncSageMakerStatus function', () => {
const roleArn = 'roleArn';
const externalId = 'externalId';
const requestContext = {};

const empty = {};

it('should finish updating before returning', async () => {
// BUILD
const sagemakerInstances = { 'notebook-instance-name': {} };
Expand All @@ -1452,7 +1450,7 @@ describe('EnvironmentSCService', () => {
);

// CHECK
await expect(sagemakerUpdated).not.toEqual(empty);
await expect(sagemakerUpdated).toEqual({ 'notebook-instance-name': 'Updated' });
});

it('should finish update all records that need it before returning', async () => {
Expand All @@ -1463,7 +1461,7 @@ describe('EnvironmentSCService', () => {
});
service.updateStatus = jest.fn(async () => {
// sleep
await new Promise(r => setTimeout(r, 4000));
await new Promise(r => setTimeout(r, 1000));
// return some non falsey value
return 'Updated';
});
Expand All @@ -1477,18 +1475,19 @@ describe('EnvironmentSCService', () => {
);

// CHECK
await expect(sagemakerUpdated).not.toEqual(empty);
await expect(sagemakerUpdated).toEqual({
'notebook-instance-name': 'Updated',
'notebook-instance-name-1': 'Updated',
});
await expect(Object.keys(sagemakerUpdated).length).toEqual(Object.keys(sagemakerInstances).length);
});
});

describe('pollAndSyncEC2Status', () => {
describe('pollAndSyncEC2Status function', () => {
const roleArn = 'roleArn';
const externalId = 'externalId';
const requestContext = {};

const empty = {};

it('should finish updating before returning', async () => {
// BUILD
const ec2Instances = { 'instance-name': {} };
Expand All @@ -1506,7 +1505,7 @@ describe('EnvironmentSCService', () => {
const ec2Updated = await service.pollAndSyncEc2Status(roleArn, externalId, ec2Instances, requestContext);

// CHECK
await expect(ec2Updated).not.toEqual(empty);
await expect(ec2Updated).toEqual({ 'instance-name': 'Updated' });
});

it('should finish update all records that need it before returning', async () => {
Expand All @@ -1517,7 +1516,7 @@ describe('EnvironmentSCService', () => {
});
service.updateStatus = jest.fn(async () => {
// sleep
await new Promise(r => setTimeout(r, 4000));
await new Promise(r => setTimeout(r, 1000));
// return some non falsey value
return 'Updated';
});
Expand All @@ -1526,7 +1525,7 @@ describe('EnvironmentSCService', () => {
const ec2Updated = await service.pollAndSyncEc2Status(roleArn, externalId, ec2Instances, requestContext);

// CHECK
await expect(ec2Updated).not.toEqual(empty);
await expect(ec2Updated).toEqual({ 'instance-name': 'Updated', 'instance-name-1': 'Updated' });
await expect(Object.keys(ec2Updated).length).toEqual(Object.keys(ec2Instances).length);
});
});
Expand Down

0 comments on commit fa2873f

Please sign in to comment.