Skip to content

Commit

Permalink
update root folder per dmr convention and remove some more tests warn…
Browse files Browse the repository at this point in the history
…ings (#614)
  • Loading branch information
YingXue authored Feb 27, 2023
1 parent b794202 commit 2dac53a
Show file tree
Hide file tree
Showing 10 changed files with 21 additions and 17 deletions.
7 changes: 4 additions & 3 deletions src/app/devices/addDevice/saga.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ describe('addDeviceSaga', () => {
const connectionString = 'connection_string';
const deviceId = 'device_id';
const mockDevice: DeviceIdentity = {
authentication: null,
capabilities: null,
authentication: null as any,
capabilities: null as any,
cloudToDeviceMessageCount: 1,
deviceId,
etag: 'etag',
Expand All @@ -39,6 +39,7 @@ describe('addDeviceSaga', () => {
deviceId,
iotEdge: true,
lastActivityTime: '',
modelId: '',
status: 'Enabled',
statusUpdatedTime: ''
};
Expand Down Expand Up @@ -77,7 +78,7 @@ describe('addDeviceSaga', () => {

expect(success.next()).toEqual({
done: false,
value: put(addDeviceAction.done({params: mockDevice, result: mockResult}))
value: put(addDeviceAction.done({params: mockDevice, result: mockResult as any}))
});

expect(success.next().done).toEqual(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,9 @@ exports[`components/devices/deviceCommandsPerInterface matches snapshot 1`] = `
componentName="urn:interfaceId"
deviceId="device1"
handleCollapseToggle={[Function]}
invokeDigitalTwinInterfaceCommand={[MockFunction]}
invokeCommand={[MockFunction]}
key="0"
moduleId=""
parsedSchema={
Object {
"description": "command1 description",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { DeviceCommandsPerInterfacePerCommand } from './deviceCommandsPerInterfa

describe('components/devices/deviceCommandsPerInterface', () => {
const deviceCommandsDispatchProps: DeviceCommandDispatchProps = {
invokeDigitalTwinInterfaceCommand: jest.fn()
invokeCommand: jest.fn()
};
const deviceCommandDataProps: DeviceCommandDataProps = {
commandSchemas: [
Expand All @@ -28,7 +28,8 @@ describe('components/devices/deviceCommandsPerInterface', () => {
}
],
componentName: 'urn:interfaceId',
deviceId: 'device1'
deviceId: 'device1',
moduleId: ''
};

const getComponent = (overrides = {}) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ describe('components/devices/deviceCommandsPerInterfacePerCommand', () => {
parsedSchema: {
description: 'command1 description',
name: 'command1'
}
},
moduleId: ''
};

const getComponent = (overrides = {}) => {
Expand Down Expand Up @@ -124,7 +125,7 @@ describe('components/devices/deviceCommandsPerInterfacePerCommand', () => {
}
}
});

const sendCommandConfirmation = wrapper.find(SendCommandConfirmation);
expect(sendCommandConfirmation.props().hidden).toEqual(false);
});
Expand Down Expand Up @@ -156,7 +157,6 @@ describe('components/devices/deviceCommandsPerInterfacePerCommand', () => {
}
}
});


const sendCommandConfirmation = wrapper.find(SendCommandConfirmation);
sendCommandConfirmation.props().onSendConfirm = onConfirmSendCommand;
Expand Down Expand Up @@ -193,14 +193,12 @@ describe('components/devices/deviceCommandsPerInterfacePerCommand', () => {
}
}
});


const sendCommandConfirmation = wrapper.find(SendCommandConfirmation);
sendCommandConfirmation.props().onSendCancel = onCancelSendCommand;
sendCommandConfirmation.props().onSendCancel();
wrapper.update();


expect(onCancelSendCommand).toHaveBeenCalled();
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ exports[`components/devices/deviceSettingsPerInterface matches snapshot 1`] = `
handleOverlayToggle={[Function]}
interfaceId="urn:contoso:com:EnvironmentalSensor;1"
key="0"
moduleId=""
patchTwin={[MockFunction]}
reportedSection={
Object {
Expand Down Expand Up @@ -158,6 +159,7 @@ exports[`components/devices/deviceSettingsPerInterface matches snapshot 1`] = `
handleOverlayToggle={[Function]}
interfaceId="urn:contoso:com:EnvironmentalSensor;1"
key="1"
moduleId=""
patchTwin={[MockFunction]}
reportedSection={
Object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ describe('components/devices/deviceSettingsPerInterface', () => {
componentName: testComponentName,
deviceId: 'testDevice',
interfaceId: 'urn:contoso:com:EnvironmentalSensor;1',
twinWithSchema
twinWithSchema,
moduleId: ''
};

const deviceSettingsDispatchProps: DeviceSettingDispatchProps = {
Expand Down
2 changes: 1 addition & 1 deletion src/app/devices/pnp/sagas/getModelDefinitionSaga.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ describe('modelDefinition sagas', () => {
getModelDefinitionAction.started({
digitalTwinId,
interfaceId,
locations: [{ repositoryLocationType: REPOSITORY_LOCATION_TYPE.LocalDMR, value: 'f:/dtmi' }],
locations: [{ repositoryLocationType: REPOSITORY_LOCATION_TYPE.LocalDMR, value: 'f:/' }],
})
);

Expand Down
2 changes: 1 addition & 1 deletion src/app/devices/pnp/sagas/utils.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,6 @@ describe('utils ', () => {
});

it('gets expected dmr params', () => {
expect(getDmrParams('d:/test/dtmi', interfaceId)).toEqual({folderPath: 'd:/test/dtmi/com/example', fileName: 'thermostat-1.json'});
expect(getDmrParams('d:/test/', interfaceId)).toEqual({folderPath: 'd:/test/dtmi/com/example', fileName: 'thermostat-1.json'});
});
});
4 changes: 2 additions & 2 deletions src/app/devices/pnp/sagas/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export const getLocationSettingValue = (locations: ModelRepositoryConfiguration[
export const getDmrParams = (path: string, interfaceId: string): {folderPath: string, fileName: string} => {
// convert dtmi name to follow drm convention
// for example: dtmi:com:example:Thermostat;1 -> dtmi/com/example/thermostat-1.json
const fullPath = path.substring(0, path.lastIndexOf('/') + 1) + `${interfaceId.toLowerCase().replace(/:/g, '/').replace(';', '-')}.json`;
// path will be converted to for example: original path/dtmi/com/example, file name will be thermostat-1.json
const fullPath = `${path.replace(/\/$/, '')}/${interfaceId.toLowerCase().replace(/:/g, '/').replace(';', '-')}.json`;
// folderPath will be converted to for example: ${path}/dtmi/com/example, and fileName will be thermostat-1.json
return {folderPath: fullPath.substring(0, fullPath.lastIndexOf('/')), fileName: fullPath.substring(fullPath.lastIndexOf('/') + 1, fullPath.length)};
};
2 changes: 1 addition & 1 deletion src/localization/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -997,7 +997,7 @@
},
"dmr": {
"label": "Local Repository",
"infoText": "Use your local folder as a model repository following the <0>resolution convention spec</0>. Please configure the file path to be your local DTMI folder."
"infoText": "Use your local folder as a model repository following the <0>resolution convention spec</0>. Please configure the file path to your root repository directory containing a sub dtmi directory."
},
"notAvailable": "--",
"mandatory": "Input is required."
Expand Down

0 comments on commit 2dac53a

Please sign in to comment.