diff --git a/lib/gui/components/drive-selector/controllers/drive-selector.js b/lib/gui/components/drive-selector/controllers/drive-selector.js index 79ad5ec9..1005120e 100644 --- a/lib/gui/components/drive-selector/controllers/drive-selector.js +++ b/lib/gui/components/drive-selector/controllers/drive-selector.js @@ -18,6 +18,7 @@ const _ = require('lodash'); const messages = require('../../../../shared/messages'); +const constraints = require('../../../../shared/drive-constraints'); module.exports = function( $q, @@ -25,7 +26,6 @@ module.exports = function( DrivesModel, SelectionStateModel, WarningModalService, - DriveConstraintsModel, AnalyticsService ) { @@ -41,7 +41,7 @@ module.exports = function( * @type {Object} * @public */ - this.constraints = DriveConstraintsModel; + this.constraints = constraints; /** * @summary The drives model @@ -71,11 +71,11 @@ module.exports = function( * }); */ const shouldChangeDriveSelectionState = (drive) => { - if (!DriveConstraintsModel.isDriveValid(drive, SelectionStateModel.getImage())) { + if (!constraints.isDriveValid(drive, SelectionStateModel.getImage())) { return $q.resolve(false); } - if (DriveConstraintsModel.isDriveSizeRecommended(drive, SelectionStateModel.getImage())) { + if (constraints.isDriveSizeRecommended(drive, SelectionStateModel.getImage())) { return $q.resolve(true); } diff --git a/lib/gui/components/drive-selector/drive-selector.js b/lib/gui/components/drive-selector/drive-selector.js index ad6f500e..d9961efa 100644 --- a/lib/gui/components/drive-selector/drive-selector.js +++ b/lib/gui/components/drive-selector/drive-selector.js @@ -27,7 +27,6 @@ const DriveSelector = angular.module(MODULE_NAME, [ require('../warning-modal/warning-modal'), require('../../models/drives'), require('../../models/selection-state'), - require('../../models/drive-constraints'), require('../../utils/byte-size/byte-size'), require('../../modules/analytics') ]); diff --git a/lib/gui/models/drive-constraints.js b/lib/gui/models/drive-constraints.js deleted file mode 100644 index 13969cb9..00000000 --- a/lib/gui/models/drive-constraints.js +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright 2016 resin.io - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -'use strict'; - -/** - * @summary Expose a CLI/GUI shared utility object as an AngularJS service - * @module Etcher.Models.DriveConstraints - */ - -const angular = require('angular'); -const MODULE_NAME = 'Etcher.Models.DriveConstraints'; -const DriveConstraintsModel = angular.module(MODULE_NAME, []); - -const DriveConstraints = require('../../shared/drive-constraints'); - -// `DriveConstraintsModel.service` expects a constructor as the second argument, but we want -// to expose an object. Calling `DriveConstraintsModel.factory` with a a function returning -// the object is the right way to do it. -DriveConstraintsModel.factory('DriveConstraintsModel', () => { - return DriveConstraints; -}); - -module.exports = MODULE_NAME; diff --git a/tests/gui/models/drive-constraints.spec.js b/tests/gui/models/drive-constraints.spec.js deleted file mode 100644 index 9cf01d01..00000000 --- a/tests/gui/models/drive-constraints.spec.js +++ /dev/null @@ -1,28 +0,0 @@ -'use strict'; - -const m = require('mochainon'); -const angular = require('angular'); -require('angular-mocks'); - -describe('Browser: DriveConstraints', function() { - - beforeEach(angular.mock.module( - require('../../../lib/gui/models/drive-constraints') - )); - - describe('DriveConstraintsModel', function() { - - let DriveConstraintsModel; - - beforeEach(angular.mock.inject(function(_DriveConstraintsModel_) { - DriveConstraintsModel = _DriveConstraintsModel_; - })); - - it('should be the `lib/shared/drive-constraints.js` object', function() { - const DriveConstraints = require('../../../lib/shared/drive-constraints'); - m.chai.expect(Object.is(DriveConstraintsModel, DriveConstraints)).to.be.true; - }); - - }); - -});