refactor: rename selection state and store functions (#2037)

We rename functions in `selection-state` and the `store`.

Change-Type: patch
Changelog-Entry: Rename selection-state and store functions.
This commit is contained in:
Benedict Aas 2018-02-13 11:15:22 +00:00 committed by GitHub
parent bb5efb3450
commit c3600ee8fc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 109 additions and 109 deletions

View File

@ -111,7 +111,7 @@ module.exports = function (
previouslySelected: selectionState.isCurrentDrive(drive.device) previouslySelected: selectionState.isCurrentDrive(drive.device)
}) })
selectionState.toggleSetDrive(drive.device) selectionState.toggleDrive(drive.device)
} }
}) })
} }
@ -155,7 +155,7 @@ module.exports = function (
this.selectDriveAndClose = (drive) => { this.selectDriveAndClose = (drive) => {
return shouldChangeDriveSelectionState(drive).then((canChangeDriveSelectionState) => { return shouldChangeDriveSelectionState(drive).then((canChangeDriveSelectionState) => {
if (canChangeDriveSelectionState) { if (canChangeDriveSelectionState) {
selectionState.setDrive(drive.device) selectionState.selectDrive(drive.device)
analytics.logEvent('Drive selected (double click)') analytics.logEvent('Drive selected (double click)')

View File

@ -36,7 +36,7 @@ module.exports = function (DriveSelectorService) {
return return
} }
selectionState.setDrive(drive.device) selectionState.selectDrive(drive.device)
analytics.logEvent('Select drive', { analytics.logEvent('Select drive', {
device: drive.device, device: drive.device,

View File

@ -105,7 +105,7 @@ module.exports = function (
return this.reselectImage() return this.reselectImage()
} }
selectionState.setImage(image) selectionState.selectImage(image)
// An easy way so we can quickly identify if we're making use of // An easy way so we can quickly identify if we're making use of
// certain features without printing pages of text to DevTools. // certain features without printing pages of text to DevTools.

View File

@ -21,49 +21,49 @@ const store = require('../store')
const availableDrives = require('./available-drives') const availableDrives = require('./available-drives')
/** /**
* @summary Set a drive * @summary Select a drive by its device path
* @function * @function
* @public * @public
* *
* @param {String} drive - drive device * @param {String} driveDevice - drive device
* *
* @example * @example
* selectionState.setDrive('/dev/disk2'); * selectionState.selectDrive('/dev/disk2');
*/ */
exports.setDrive = (drive) => { exports.selectDrive = (driveDevice) => {
store.dispatch({ store.dispatch({
type: store.Actions.SELECT_DRIVE, type: store.Actions.SELECT_DRIVE,
data: drive data: driveDevice
}) })
} }
/** /**
* @summary Toggle set drive * @summary Toggle drive selection
* @function * @function
* @public * @public
* *
* @param {String} drive - drive device * @param {String} driveDevice - drive device
* *
* @example * @example
* selectionState.toggleSetDrive('/dev/disk2'); * selectionState.toggleDrive('/dev/disk2');
*/ */
exports.toggleSetDrive = (drive) => { exports.toggleDrive = (driveDevice) => {
if (exports.isCurrentDrive(drive)) { if (exports.isCurrentDrive(driveDevice)) {
exports.removeDrive() exports.deselectDrive()
} else { } else {
exports.setDrive(drive) exports.selectDrive(driveDevice)
} }
} }
/** /**
* @summary Set a image * @summary Select an image
* @function * @function
* @public * @public
* *
* @param {Object} image - image * @param {Object} image - image
* *
* @example * @example
* selectionState.setImage({ * selectionState.selectImage({
* path: 'foo.img', * path: 'foo.img',
* size: { * size: {
* original: 1000000000, * original: 1000000000,
@ -74,7 +74,7 @@ exports.toggleSetDrive = (drive) => {
* } * }
* }); * });
*/ */
exports.setImage = (image) => { exports.selectImage = (image) => {
store.dispatch({ store.dispatch({
type: store.Actions.SELECT_IMAGE, type: store.Actions.SELECT_IMAGE,
data: image data: image
@ -277,25 +277,25 @@ exports.hasImage = () => {
* @public * @public
* *
* @example * @example
* selectionState.removeDrive(); * selectionState.deselectDrive();
*/ */
exports.removeDrive = () => { exports.deselectDrive = () => {
store.dispatch({ store.dispatch({
type: store.Actions.REMOVE_DRIVE type: store.Actions.DESELECT_DRIVE
}) })
} }
/** /**
* @summary Remove image * @summary Deselect image
* @function * @function
* @public * @public
* *
* @example * @example
* selectionState.removeImage(); * selectionState.deselectImage();
*/ */
exports.removeImage = () => { exports.deselectImage = () => {
store.dispatch({ store.dispatch({
type: store.Actions.REMOVE_IMAGE type: store.Actions.DESELECT_IMAGE
}) })
} }
@ -316,12 +316,12 @@ exports.removeImage = () => {
exports.clear = (options = {}) => { exports.clear = (options = {}) => {
if (!options.preserveImage) { if (!options.preserveImage) {
store.dispatch({ store.dispatch({
type: store.Actions.REMOVE_IMAGE type: store.Actions.DESELECT_IMAGE
}) })
} }
store.dispatch({ store.dispatch({
type: store.Actions.REMOVE_DRIVE type: store.Actions.DESELECT_DRIVE
}) })
} }
@ -330,7 +330,7 @@ exports.clear = (options = {}) => {
* @function * @function
* @public * @public
* *
* @param {String} drive - drive device * @param {String} driveDevice - drive device
* @returns {Boolean} whether the drive is the current drive * @returns {Boolean} whether the drive is the current drive
* *
* @example * @example
@ -338,10 +338,10 @@ exports.clear = (options = {}) => {
* console.log('This is the current drive!'); * console.log('This is the current drive!');
* } * }
*/ */
exports.isCurrentDrive = (drive) => { exports.isCurrentDrive = (driveDevice) => {
if (!drive) { if (!driveDevice) {
return false return false
} }
return drive === _.get(exports.getDrive(), [ 'device' ]) return driveDevice === _.get(exports.getDrive(), [ 'device' ])
} }

View File

@ -68,8 +68,8 @@ const ACTIONS = _.fromPairs(_.map([
'UNSET_FLASHING_FLAG', 'UNSET_FLASHING_FLAG',
'SELECT_DRIVE', 'SELECT_DRIVE',
'SELECT_IMAGE', 'SELECT_IMAGE',
'REMOVE_DRIVE', 'DESELECT_DRIVE',
'REMOVE_IMAGE', 'DESELECT_IMAGE',
'SET_SETTINGS' 'SET_SETTINGS'
], (message) => { ], (message) => {
return [ message, message ] return [ message, message ]
@ -108,7 +108,7 @@ const findDrive = (state, device) => {
* *
* @example * @example
* const newState = storeReducer(DEFAULT_STATE, { * const newState = storeReducer(DEFAULT_STATE, {
* type: ACTIONS.REMOVE_DRIVE * type: ACTIONS.DESELECT_DRIVE
* }); * });
*/ */
const storeReducer = (state = DEFAULT_STATE, action) => { const storeReducer = (state = DEFAULT_STATE, action) => {
@ -162,7 +162,7 @@ const storeReducer = (state = DEFAULT_STATE, action) => {
device: selectedDevice device: selectedDevice
})) { })) {
return storeReducer(newState, { return storeReducer(newState, {
type: ACTIONS.REMOVE_DRIVE type: ACTIONS.DESELECT_DRIVE
}) })
} }
@ -429,7 +429,7 @@ const storeReducer = (state = DEFAULT_STATE, action) => {
constraints.isDriveSizeRecommended(selectedDrive.toJS(), action.data) constraints.isDriveSizeRecommended(selectedDrive.toJS(), action.data)
])) { ])) {
return storeReducer(state, { return storeReducer(state, {
type: ACTIONS.REMOVE_DRIVE type: ACTIONS.DESELECT_DRIVE
}) })
} }
@ -437,11 +437,11 @@ const storeReducer = (state = DEFAULT_STATE, action) => {
}).setIn([ 'selection', 'image' ], Immutable.fromJS(action.data)) }).setIn([ 'selection', 'image' ], Immutable.fromJS(action.data))
} }
case ACTIONS.REMOVE_DRIVE: { case ACTIONS.DESELECT_DRIVE: {
return state.deleteIn([ 'selection', 'drive' ]) return state.deleteIn([ 'selection', 'drive' ])
} }
case ACTIONS.REMOVE_IMAGE: { case ACTIONS.DESELECT_IMAGE: {
return state.deleteIn([ 'selection', 'image' ]) return state.deleteIn([ 'selection', 'image' ])
} }

View File

@ -54,7 +54,7 @@ describe('Browser: MainPage', function () {
$scope: {} $scope: {}
}) })
selectionState.setImage({ selectionState.selectImage({
path: 'rpi.img', path: 'rpi.img',
extension: 'img', extension: 'img',
size: { size: {
@ -87,7 +87,7 @@ describe('Browser: MainPage', function () {
}) })
selectionState.clear() selectionState.clear()
selectionState.setImage({ selectionState.selectImage({
path: 'rpi.img', path: 'rpi.img',
extension: 'img', extension: 'img',
size: { size: {
@ -118,7 +118,7 @@ describe('Browser: MainPage', function () {
]) ])
selectionState.clear() selectionState.clear()
selectionState.setDrive('/dev/disk2') selectionState.selectDrive('/dev/disk2')
m.chai.expect(controller.shouldFlashStepBeDisabled()).to.be.true m.chai.expect(controller.shouldFlashStepBeDisabled()).to.be.true
}) })
@ -139,9 +139,9 @@ describe('Browser: MainPage', function () {
]) ])
selectionState.clear() selectionState.clear()
selectionState.setDrive('/dev/disk2') selectionState.selectDrive('/dev/disk2')
selectionState.setImage({ selectionState.selectImage({
path: 'rpi.img', path: 'rpi.img',
extension: 'img', extension: 'img',
size: { size: {
@ -181,7 +181,7 @@ describe('Browser: MainPage', function () {
$scope: {} $scope: {}
}) })
selectionState.setImage({ selectionState.selectImage({
path: path.join(__dirname, 'foo', 'bar.img'), path: path.join(__dirname, 'foo', 'bar.img'),
extension: 'img', extension: 'img',
size: { size: {
@ -194,7 +194,7 @@ describe('Browser: MainPage', function () {
}) })
m.chai.expect(controller.getImageBasename()).to.equal('bar.img') m.chai.expect(controller.getImageBasename()).to.equal('bar.img')
selectionState.removeImage() selectionState.deselectImage()
}) })
it('should return an empty string if no selected image', function () { it('should return an empty string if no selected image', function () {
@ -202,7 +202,7 @@ describe('Browser: MainPage', function () {
$scope: {} $scope: {}
}) })
selectionState.removeImage() selectionState.deselectImage()
m.chai.expect(controller.getImageBasename()).to.equal('') m.chai.expect(controller.getImageBasename()).to.equal('')
}) })
}) })

View File

@ -142,8 +142,8 @@ describe('Model: availableDrives', function () {
describe('given no selected image and no selected drive', function () { describe('given no selected image and no selected drive', function () {
beforeEach(function () { beforeEach(function () {
selectionState.removeDrive() selectionState.deselectDrive()
selectionState.removeImage() selectionState.deselectImage()
}) })
it('should auto-select a single valid available drive', function () { it('should auto-select a single valid available drive', function () {
@ -175,8 +175,8 @@ describe('Model: availableDrives', function () {
this.imagePath = '/mnt/bar/foo.img' this.imagePath = '/mnt/bar/foo.img'
} }
selectionState.removeDrive() selectionState.deselectDrive()
selectionState.setImage({ selectionState.selectImage({
path: this.imagePath, path: this.imagePath,
extension: 'img', extension: 'img',
size: { size: {
@ -191,7 +191,7 @@ describe('Model: availableDrives', function () {
}) })
afterEach(function () { afterEach(function () {
selectionState.removeImage() selectionState.deselectImage()
}) })
it('should not auto-select when there are multiple valid available drives', function () { it('should not auto-select when there are multiple valid available drives', function () {
@ -394,11 +394,11 @@ describe('Model: availableDrives', function () {
} }
]) ])
selectionState.setDrive('/dev/sdc') selectionState.selectDrive('/dev/sdc')
}) })
afterEach(function () { afterEach(function () {
selectionState.removeDrive() selectionState.deselectDrive()
}) })
it('should be deleted if its not contained in the available drives anymore', function () { it('should be deleted if its not contained in the available drives anymore', function () {

View File

@ -93,7 +93,7 @@ describe('Model: selectionState', function () {
} }
]) ])
selectionState.setDrive('/dev/disk2') selectionState.selectDrive('/dev/disk2')
}) })
describe('.getDrive()', function () { describe('.getDrive()', function () {
@ -117,7 +117,7 @@ describe('Model: selectionState', function () {
describe('.setDrive()', function () { describe('.setDrive()', function () {
it('should override the drive', function () { it('should override the drive', function () {
selectionState.setDrive('/dev/disk5') selectionState.selectDrive('/dev/disk5')
const drive = selectionState.getDrive() const drive = selectionState.getDrive()
m.chai.expect(drive).to.deep.equal({ m.chai.expect(drive).to.deep.equal({
device: '/dev/disk5', device: '/dev/disk5',
@ -130,7 +130,7 @@ describe('Model: selectionState', function () {
describe('.removeDrive()', function () { describe('.removeDrive()', function () {
it('should clear the drive', function () { it('should clear the drive', function () {
selectionState.removeDrive() selectionState.deselectDrive()
const drive = selectionState.getDrive() const drive = selectionState.getDrive()
m.chai.expect(drive).to.be.undefined m.chai.expect(drive).to.be.undefined
}) })
@ -149,7 +149,7 @@ describe('Model: selectionState', function () {
} }
]) ])
selectionState.setDrive('/dev/disk5') selectionState.selectDrive('/dev/disk5')
const drive = selectionState.getDrive() const drive = selectionState.getDrive()
m.chai.expect(drive).to.deep.equal({ m.chai.expect(drive).to.deep.equal({
device: '/dev/disk5', device: '/dev/disk5',
@ -170,7 +170,7 @@ describe('Model: selectionState', function () {
]) ])
m.chai.expect(function () { m.chai.expect(function () {
selectionState.setDrive('/dev/disk1') selectionState.selectDrive('/dev/disk1')
}).to.throw('The drive is write-protected') }).to.throw('The drive is write-protected')
}) })
@ -185,13 +185,13 @@ describe('Model: selectionState', function () {
]) ])
m.chai.expect(function () { m.chai.expect(function () {
selectionState.setDrive('/dev/disk5') selectionState.selectDrive('/dev/disk5')
}).to.throw('The drive is not available: /dev/disk5') }).to.throw('The drive is not available: /dev/disk5')
}) })
it('should throw if device is not a string', function () { it('should throw if device is not a string', function () {
m.chai.expect(function () { m.chai.expect(function () {
selectionState.setDrive(123) selectionState.selectDrive(123)
}).to.throw('Invalid drive: 123') }).to.throw('Invalid drive: 123')
}) })
}) })
@ -216,7 +216,7 @@ describe('Model: selectionState', function () {
logo: '<svg><text fill="red">Raspbian</text></svg>' logo: '<svg><text fill="red">Raspbian</text></svg>'
} }
selectionState.setImage(this.image) selectionState.selectImage(this.image)
}) })
describe('.setDrive()', function () { describe('.setDrive()', function () {
@ -231,7 +231,7 @@ describe('Model: selectionState', function () {
]) ])
m.chai.expect(function () { m.chai.expect(function () {
selectionState.setDrive('/dev/disk2') selectionState.selectDrive('/dev/disk2')
}).to.throw('The drive is not large enough') }).to.throw('The drive is not large enough')
}) })
}) })
@ -300,7 +300,7 @@ describe('Model: selectionState', function () {
describe('.setImage()', function () { describe('.setImage()', function () {
it('should override the image', function () { it('should override the image', function () {
selectionState.setImage({ selectionState.selectImage({
path: 'bar.img', path: 'bar.img',
extension: 'img', extension: 'img',
size: { size: {
@ -321,7 +321,7 @@ describe('Model: selectionState', function () {
describe('.removeImage()', function () { describe('.removeImage()', function () {
it('should clear the image', function () { it('should clear the image', function () {
selectionState.removeImage() selectionState.deselectImage()
const imagePath = selectionState.getImagePath() const imagePath = selectionState.getImagePath()
m.chai.expect(imagePath).to.be.undefined m.chai.expect(imagePath).to.be.undefined
@ -334,7 +334,7 @@ describe('Model: selectionState', function () {
describe('given no image', function () { describe('given no image', function () {
describe('.setImage()', function () { describe('.setImage()', function () {
it('should be able to set an image', function () { it('should be able to set an image', function () {
selectionState.setImage({ selectionState.selectImage({
path: 'foo.img', path: 'foo.img',
extension: 'img', extension: 'img',
size: { size: {
@ -353,7 +353,7 @@ describe('Model: selectionState', function () {
}) })
it('should be able to set an image with an archive extension', function () { it('should be able to set an image with an archive extension', function () {
selectionState.setImage({ selectionState.selectImage({
path: 'foo.zip', path: 'foo.zip',
extension: 'img', extension: 'img',
archiveExtension: 'zip', archiveExtension: 'zip',
@ -371,7 +371,7 @@ describe('Model: selectionState', function () {
}) })
it('should infer a compressed raw image if the penultimate extension is missing', function () { it('should infer a compressed raw image if the penultimate extension is missing', function () {
selectionState.setImage({ selectionState.selectImage({
path: 'foo.xz', path: 'foo.xz',
extension: 'img', extension: 'img',
archiveExtension: 'xz', archiveExtension: 'xz',
@ -389,7 +389,7 @@ describe('Model: selectionState', function () {
}) })
it('should infer a compressed raw image if the penultimate extension is not a file extension', function () { it('should infer a compressed raw image if the penultimate extension is not a file extension', function () {
selectionState.setImage({ selectionState.selectImage({
path: 'something.linux-x86-64.gz', path: 'something.linux-x86-64.gz',
extension: 'img', extension: 'img',
archiveExtension: 'gz', archiveExtension: 'gz',
@ -408,7 +408,7 @@ describe('Model: selectionState', function () {
it('should throw if no path', function () { it('should throw if no path', function () {
m.chai.expect(function () { m.chai.expect(function () {
selectionState.setImage({ selectionState.selectImage({
extension: 'img', extension: 'img',
size: { size: {
original: 999999999, original: 999999999,
@ -423,7 +423,7 @@ describe('Model: selectionState', function () {
it('should throw if path is not a string', function () { it('should throw if path is not a string', function () {
m.chai.expect(function () { m.chai.expect(function () {
selectionState.setImage({ selectionState.selectImage({
path: 123, path: 123,
extension: 'img', extension: 'img',
size: { size: {
@ -439,7 +439,7 @@ describe('Model: selectionState', function () {
it('should throw if no extension', function () { it('should throw if no extension', function () {
m.chai.expect(function () { m.chai.expect(function () {
selectionState.setImage({ selectionState.selectImage({
path: 'foo.img', path: 'foo.img',
size: { size: {
original: 999999999, original: 999999999,
@ -454,7 +454,7 @@ describe('Model: selectionState', function () {
it('should throw if extension is not a string', function () { it('should throw if extension is not a string', function () {
m.chai.expect(function () { m.chai.expect(function () {
selectionState.setImage({ selectionState.selectImage({
path: 'foo.img', path: 'foo.img',
extension: 1, extension: 1,
size: { size: {
@ -470,7 +470,7 @@ describe('Model: selectionState', function () {
it('should throw if the extension doesn\'t match the path and there is no archive extension', function () { it('should throw if the extension doesn\'t match the path and there is no archive extension', function () {
m.chai.expect(function () { m.chai.expect(function () {
selectionState.setImage({ selectionState.selectImage({
path: 'foo.img', path: 'foo.img',
extension: 'iso', extension: 'iso',
size: { size: {
@ -486,7 +486,7 @@ describe('Model: selectionState', function () {
it('should throw if the extension doesn\'t match the path and the archive extension is not a string', function () { it('should throw if the extension doesn\'t match the path and the archive extension is not a string', function () {
m.chai.expect(function () { m.chai.expect(function () {
selectionState.setImage({ selectionState.selectImage({
path: 'foo.img', path: 'foo.img',
extension: 'iso', extension: 'iso',
archiveExtension: 1, archiveExtension: 1,
@ -503,7 +503,7 @@ describe('Model: selectionState', function () {
it('should throw if the archive extension doesn\'t match the last path extension in a compressed image', function () { it('should throw if the archive extension doesn\'t match the last path extension in a compressed image', function () {
m.chai.expect(function () { m.chai.expect(function () {
selectionState.setImage({ selectionState.selectImage({
path: 'foo.img.xz', path: 'foo.img.xz',
extension: 'img', extension: 'img',
archiveExtension: 'gz', archiveExtension: 'gz',
@ -520,7 +520,7 @@ describe('Model: selectionState', function () {
it('should throw if the extension is not recognised in an uncompressed image', function () { it('should throw if the extension is not recognised in an uncompressed image', function () {
m.chai.expect(function () { m.chai.expect(function () {
selectionState.setImage({ selectionState.selectImage({
path: 'foo.ifg', path: 'foo.ifg',
extension: 'ifg', extension: 'ifg',
size: { size: {
@ -536,7 +536,7 @@ describe('Model: selectionState', function () {
it('should throw if the extension is not recognised in a compressed image', function () { it('should throw if the extension is not recognised in a compressed image', function () {
m.chai.expect(function () { m.chai.expect(function () {
selectionState.setImage({ selectionState.selectImage({
path: 'foo.ifg.gz', path: 'foo.ifg.gz',
extension: 'ifg', extension: 'ifg',
archiveExtension: 'gz', archiveExtension: 'gz',
@ -553,7 +553,7 @@ describe('Model: selectionState', function () {
it('should throw if the archive extension is not recognised', function () { it('should throw if the archive extension is not recognised', function () {
m.chai.expect(function () { m.chai.expect(function () {
selectionState.setImage({ selectionState.selectImage({
path: 'foo.img.ifg', path: 'foo.img.ifg',
extension: 'img', extension: 'img',
archiveExtension: 'ifg', archiveExtension: 'ifg',
@ -570,7 +570,7 @@ describe('Model: selectionState', function () {
it('should throw if no size', function () { it('should throw if no size', function () {
m.chai.expect(function () { m.chai.expect(function () {
selectionState.setImage({ selectionState.selectImage({
path: 'foo.img', path: 'foo.img',
extension: 'img' extension: 'img'
}) })
@ -579,7 +579,7 @@ describe('Model: selectionState', function () {
it('should throw if size is not a plain object', function () { it('should throw if size is not a plain object', function () {
m.chai.expect(function () { m.chai.expect(function () {
selectionState.setImage({ selectionState.selectImage({
path: 'foo.img', path: 'foo.img',
extension: 'img', extension: 'img',
size: 999999999 size: 999999999
@ -589,7 +589,7 @@ describe('Model: selectionState', function () {
it('should throw if the original size is not a number', function () { it('should throw if the original size is not a number', function () {
m.chai.expect(function () { m.chai.expect(function () {
selectionState.setImage({ selectionState.selectImage({
path: 'foo.img', path: 'foo.img',
extension: 'img', extension: 'img',
size: { size: {
@ -605,7 +605,7 @@ describe('Model: selectionState', function () {
it('should throw if the original size is a float number', function () { it('should throw if the original size is a float number', function () {
m.chai.expect(function () { m.chai.expect(function () {
selectionState.setImage({ selectionState.selectImage({
path: 'foo.img', path: 'foo.img',
extension: 'img', extension: 'img',
size: { size: {
@ -621,7 +621,7 @@ describe('Model: selectionState', function () {
it('should throw if the original size is negative', function () { it('should throw if the original size is negative', function () {
m.chai.expect(function () { m.chai.expect(function () {
selectionState.setImage({ selectionState.selectImage({
path: 'foo.img', path: 'foo.img',
extension: 'img', extension: 'img',
size: { size: {
@ -637,7 +637,7 @@ describe('Model: selectionState', function () {
it('should throw if the final size is not a number', function () { it('should throw if the final size is not a number', function () {
m.chai.expect(function () { m.chai.expect(function () {
selectionState.setImage({ selectionState.selectImage({
path: 'foo.img', path: 'foo.img',
extension: 'img', extension: 'img',
size: { size: {
@ -653,7 +653,7 @@ describe('Model: selectionState', function () {
it('should throw if the final size is a float number', function () { it('should throw if the final size is a float number', function () {
m.chai.expect(function () { m.chai.expect(function () {
selectionState.setImage({ selectionState.selectImage({
path: 'foo.img', path: 'foo.img',
extension: 'img', extension: 'img',
size: { size: {
@ -669,7 +669,7 @@ describe('Model: selectionState', function () {
it('should throw if the final size is negative', function () { it('should throw if the final size is negative', function () {
m.chai.expect(function () { m.chai.expect(function () {
selectionState.setImage({ selectionState.selectImage({
path: 'foo.img', path: 'foo.img',
extension: 'img', extension: 'img',
size: { size: {
@ -685,7 +685,7 @@ describe('Model: selectionState', function () {
it('should throw if the final size estimation flag is not a boolean', function () { it('should throw if the final size estimation flag is not a boolean', function () {
m.chai.expect(function () { m.chai.expect(function () {
selectionState.setImage({ selectionState.selectImage({
path: 'foo.img', path: 'foo.img',
extension: 'img', extension: 'img',
size: { size: {
@ -701,7 +701,7 @@ describe('Model: selectionState', function () {
it('should throw if url is defined but it\'s not a string', function () { it('should throw if url is defined but it\'s not a string', function () {
m.chai.expect(function () { m.chai.expect(function () {
selectionState.setImage({ selectionState.selectImage({
path: 'foo.img', path: 'foo.img',
extension: 'img', extension: 'img',
size: { size: {
@ -718,7 +718,7 @@ describe('Model: selectionState', function () {
it('should throw if name is defined but it\'s not a string', function () { it('should throw if name is defined but it\'s not a string', function () {
m.chai.expect(function () { m.chai.expect(function () {
selectionState.setImage({ selectionState.selectImage({
path: 'foo.img', path: 'foo.img',
extension: 'img', extension: 'img',
size: { size: {
@ -735,7 +735,7 @@ describe('Model: selectionState', function () {
it('should throw if logo is defined but it\'s not a string', function () { it('should throw if logo is defined but it\'s not a string', function () {
m.chai.expect(function () { m.chai.expect(function () {
selectionState.setImage({ selectionState.selectImage({
path: 'foo.img', path: 'foo.img',
extension: 'img', extension: 'img',
size: { size: {
@ -760,10 +760,10 @@ describe('Model: selectionState', function () {
} }
]) ])
selectionState.setDrive('/dev/disk1') selectionState.selectDrive('/dev/disk1')
m.chai.expect(selectionState.hasDrive()).to.be.true m.chai.expect(selectionState.hasDrive()).to.be.true
selectionState.setImage({ selectionState.selectImage({
path: 'foo.img', path: 'foo.img',
extension: 'img', extension: 'img',
size: { size: {
@ -776,7 +776,7 @@ describe('Model: selectionState', function () {
}) })
m.chai.expect(selectionState.hasDrive()).to.be.false m.chai.expect(selectionState.hasDrive()).to.be.false
selectionState.removeImage() selectionState.deselectImage()
}) })
it('should de-select a previously selected not-recommended drive', function () { it('should de-select a previously selected not-recommended drive', function () {
@ -789,10 +789,10 @@ describe('Model: selectionState', function () {
} }
]) ])
selectionState.setDrive('/dev/disk1') selectionState.selectDrive('/dev/disk1')
m.chai.expect(selectionState.hasDrive()).to.be.true m.chai.expect(selectionState.hasDrive()).to.be.true
selectionState.setImage({ selectionState.selectImage({
path: 'foo.img', path: 'foo.img',
extension: 'img', extension: 'img',
size: { size: {
@ -806,7 +806,7 @@ describe('Model: selectionState', function () {
}) })
m.chai.expect(selectionState.hasDrive()).to.be.false m.chai.expect(selectionState.hasDrive()).to.be.false
selectionState.removeImage() selectionState.deselectImage()
}) })
it('should de-select a previously selected source drive', function () { it('should de-select a previously selected source drive', function () {
@ -832,10 +832,10 @@ describe('Model: selectionState', function () {
} }
]) ])
selectionState.setDrive('/dev/disk1') selectionState.selectDrive('/dev/disk1')
m.chai.expect(selectionState.hasDrive()).to.be.true m.chai.expect(selectionState.hasDrive()).to.be.true
selectionState.setImage({ selectionState.selectImage({
path: imagePath, path: imagePath,
extension: 'img', extension: 'img',
size: { size: {
@ -848,7 +848,7 @@ describe('Model: selectionState', function () {
}) })
m.chai.expect(selectionState.hasDrive()).to.be.false m.chai.expect(selectionState.hasDrive()).to.be.false
selectionState.removeImage() selectionState.deselectImage()
}) })
}) })
}) })
@ -864,9 +864,9 @@ describe('Model: selectionState', function () {
} }
]) ])
selectionState.setDrive('/dev/disk1') selectionState.selectDrive('/dev/disk1')
selectionState.setImage({ selectionState.selectImage({
path: 'foo.img', path: 'foo.img',
extension: 'img', extension: 'img',
size: { size: {
@ -942,7 +942,7 @@ describe('Model: selectionState', function () {
} }
]) ])
selectionState.setDrive('/dev/sdb') selectionState.selectDrive('/dev/sdb')
}) })
it('should return false if an undefined value is passed', function () { it('should return false if an undefined value is passed', function () {
@ -960,7 +960,7 @@ describe('Model: selectionState', function () {
describe('given no selected drive', function () { describe('given no selected drive', function () {
beforeEach(function () { beforeEach(function () {
selectionState.removeDrive() selectionState.deselectDrive()
}) })
it('should return false if an undefined value is passed', function () { it('should return false if an undefined value is passed', function () {
@ -998,12 +998,12 @@ describe('Model: selectionState', function () {
} }
]) ])
selectionState.setDrive(this.drive.device) selectionState.selectDrive(this.drive.device)
}) })
it('should be able to remove the drive', function () { it('should be able to remove the drive', function () {
m.chai.expect(selectionState.hasDrive()).to.be.true m.chai.expect(selectionState.hasDrive()).to.be.true
selectionState.toggleSetDrive(this.drive.device) selectionState.toggleDrive(this.drive.device)
m.chai.expect(selectionState.hasDrive()).to.be.false m.chai.expect(selectionState.hasDrive()).to.be.false
}) })
@ -1016,7 +1016,7 @@ describe('Model: selectionState', function () {
} }
m.chai.expect(selectionState.getDrive()).to.deep.equal(this.drive) m.chai.expect(selectionState.getDrive()).to.deep.equal(this.drive)
selectionState.toggleSetDrive(drive.device) selectionState.toggleDrive(drive.device)
m.chai.expect(selectionState.getDrive()).to.deep.equal(drive) m.chai.expect(selectionState.getDrive()).to.deep.equal(drive)
m.chai.expect(selectionState.getDrive()).to.not.deep.equal(this.drive) m.chai.expect(selectionState.getDrive()).to.not.deep.equal(this.drive)
}) })
@ -1024,7 +1024,7 @@ describe('Model: selectionState', function () {
describe('given no selected drive', function () { describe('given no selected drive', function () {
beforeEach(function () { beforeEach(function () {
selectionState.removeDrive() selectionState.deselectDrive()
}) })
it('should set the drive', function () { it('should set the drive', function () {
@ -1036,7 +1036,7 @@ describe('Model: selectionState', function () {
} }
m.chai.expect(selectionState.hasDrive()).to.be.false m.chai.expect(selectionState.hasDrive()).to.be.false
selectionState.toggleSetDrive(drive.device) selectionState.toggleDrive(drive.device)
m.chai.expect(selectionState.getDrive()).to.deep.equal(drive) m.chai.expect(selectionState.getDrive()).to.deep.equal(drive)
}) })
}) })