mirror of
https://github.com/balena-io/etcher.git
synced 2025-07-21 10:16:32 +00:00
fix(GUI): display untitled device when device lacks description
We fallback to `'Untitled Device'` when the device lacks a `.description` field. Change-Type: patch Changelog-Entry: Display Untitled Device when the device lacks a description field.
This commit is contained in:
parent
347932b213
commit
d59ebad167
@ -39,7 +39,7 @@ module.exports = function (DriveSelectorService) {
|
||||
|
||||
// eslint-disable-next-line no-magic-numbers
|
||||
if (drives.length === 1) {
|
||||
return _.head(drives).description
|
||||
return _.head(drives).description || 'Untitled Device'
|
||||
}
|
||||
|
||||
return `${drives.length} Devices`
|
||||
|
@ -260,8 +260,8 @@ describe('Browser: MainPage', function () {
|
||||
let DriveSelectionController
|
||||
|
||||
const drivePaths = process.platform === 'win32'
|
||||
? [ 'E:\\', 'F:\\' ]
|
||||
: [ '/dev/disk1', '/dev/disk2' ]
|
||||
? [ '\\\\.\\PhysicalDrive1', '\\\\.\\PhysicalDrive2', '\\\\.\\PhysicalDrive3' ]
|
||||
: [ '/dev/disk1', '/dev/disk2', '/dev/disk3' ]
|
||||
const drives = [
|
||||
{
|
||||
device: drivePaths[0],
|
||||
@ -280,6 +280,14 @@ describe('Browser: MainPage', function () {
|
||||
mountpoints: [ drivePaths[1] ],
|
||||
isSystem: false,
|
||||
isReadOnly: false
|
||||
},
|
||||
{
|
||||
device: drivePaths[2],
|
||||
size: 987654321,
|
||||
displayName: drivePaths[2],
|
||||
mountpoints: [],
|
||||
isSystem: false,
|
||||
isReadOnly: false
|
||||
}
|
||||
]
|
||||
|
||||
@ -302,6 +310,11 @@ describe('Browser: MainPage', function () {
|
||||
m.chai.expect(DriveSelectionController.getDrivesTitle()).to.equal(drives[0].description)
|
||||
})
|
||||
|
||||
it('should return untitled when there is no description', function () {
|
||||
selectionState.selectDrive(drives[2].device)
|
||||
m.chai.expect(DriveSelectionController.getDrivesTitle()).to.equal('Untitled Device')
|
||||
})
|
||||
|
||||
it('should return a consolidated title with quantity when there are multiple drives', function () {
|
||||
selectionState.selectDrive(drives[0].device)
|
||||
selectionState.selectDrive(drives[1].device)
|
||||
|
Loading…
x
Reference in New Issue
Block a user