From 42db5992fa8b9cda337f1f796780b168b6bfe5bf Mon Sep 17 00:00:00 2001 From: Juan Cruz Viotti Date: Wed, 13 Apr 2016 13:34:31 -0400 Subject: [PATCH] Reorganize utilities and desktop integration modules (#316) - Rename `Etcher.Utils.Dropzone` to `Etcher.OS.Dropzone` - Rename `Etcher.Utils.OpenExternal` to `Etcher.OS.OpenExternal` - Rename `Etcher.Utils.WindowProgress` to `Etcher.OS.WindowProgress` - Rename `Etcher.notification` to `Etcher.OS.Notification` - Rename `Etcher.notifier` to `Etcher.Utils.Notifier` - Rename `Etcher.path` to `Etcher.Utils.Path` Signed-off-by: Juan Cruz Viotti --- lib/browser/app.js | 38 ++++++++++--------- lib/browser/modules/image-writer.js | 4 +- .../dropzone/directives/dropzone.js | 6 +-- .../{utils => os}/dropzone/dropzone.js | 6 +-- lib/browser/os/notification/notification.js | 28 ++++++++++++++ .../notification/services}/notification.js | 17 +++------ .../open-external/directives/open-external.js | 8 ++-- .../open-external/open-external.js | 6 +-- .../services/window-progress.js | 4 +- .../window-progress/window-progress.js | 6 +-- lib/browser/utils/notifier/notifier.js | 28 ++++++++++++++ .../notifier/services}/notifier.js | 11 +----- .../path/filters/basename.js} | 12 ++---- lib/browser/utils/path/path.js | 28 ++++++++++++++ lib/index.html | 8 ++-- lib/partials/main.html | 2 +- lib/scss/main.scss | 2 +- tests/browser/{utils => os}/dropzone.spec.js | 12 +++--- .../{utils => os}/open-external.spec.js | 12 +++--- .../{utils => os}/window-progress.spec.js | 28 +++++++------- .../{modules => utils}/notifier.spec.js | 4 +- tests/browser/{modules => utils}/path.spec.js | 4 +- 22 files changed, 170 insertions(+), 104 deletions(-) rename lib/browser/{utils => os}/dropzone/directives/dropzone.js (93%) rename lib/browser/{utils => os}/dropzone/dropzone.js (80%) create mode 100644 lib/browser/os/notification/notification.js rename lib/browser/{modules => os/notification/services}/notification.js (79%) rename lib/browser/{utils => os}/open-external/directives/open-external.js (91%) rename lib/browser/{utils => os}/open-external/open-external.js (77%) rename lib/browser/{utils => os}/window-progress/services/window-progress.js (95%) rename lib/browser/{utils => os}/window-progress/window-progress.js (80%) create mode 100644 lib/browser/utils/notifier/notifier.js rename lib/browser/{modules => utils/notifier/services}/notifier.js (89%) rename lib/browser/{modules/path.js => utils/path/filters/basename.js} (83%) create mode 100644 lib/browser/utils/path/path.js rename tests/browser/{utils => os}/dropzone.spec.js (82%) rename tests/browser/{utils => os}/open-external.spec.js (80%) rename tests/browser/{utils => os}/window-progress.spec.js (73%) rename tests/browser/{modules => utils}/notifier.spec.js (92%) rename tests/browser/{modules => utils}/path.spec.js (87%) diff --git a/lib/browser/app.js b/lib/browser/app.js index c941effd..a276384d 100644 --- a/lib/browser/app.js +++ b/lib/browser/app.js @@ -30,30 +30,27 @@ require('angular-ui-router'); require('./browser/models/selection-state'); require('./browser/modules/drive-scanner'); require('./browser/modules/image-writer'); -require('./browser/modules/path'); -require('./browser/modules/notifier'); require('./browser/modules/analytics'); -require('./browser/modules/notification'); require('./browser/components/progress-button/progress-button'); require('./browser/components/drive-selector/drive-selector'); require('./browser/pages/finish/finish'); require('./browser/pages/settings/settings'); -require('./browser/utils/window-progress/window-progress'); -require('./browser/utils/open-external/open-external'); +require('./browser/os/notification/notification'); +require('./browser/os/window-progress/window-progress'); +require('./browser/os/open-external/open-external'); +require('./browser/os/dropzone/dropzone'); require('./browser/utils/if-state/if-state'); -require('./browser/utils/dropzone/dropzone'); +require('./browser/utils/notifier/notifier'); +require('./browser/utils/path/path'); const app = angular.module('Etcher', [ 'ui.router', 'ui.bootstrap', // Etcher modules - 'Etcher.path', 'Etcher.drive-scanner', 'Etcher.image-writer', - 'Etcher.notifier', 'Etcher.analytics', - 'Etcher.notification', // Models 'Etcher.Models.SelectionState', @@ -67,11 +64,16 @@ const app = angular.module('Etcher', [ 'Etcher.Pages.Finish', 'Etcher.Pages.Settings', + // OS + 'Etcher.OS.WindowProgress', + 'Etcher.OS.OpenExternal', + 'Etcher.OS.Dropzone', + 'Etcher.OS.Notification', + // Utils - 'Etcher.Utils.WindowProgress', - 'Etcher.Utils.OpenExternal', 'Etcher.Utils.IfState', - 'Etcher.Utils.Dropzone' + 'Etcher.Utils.Notifier', + 'Etcher.Utils.Path' ]); app.run(function(AnalyticsService) { @@ -100,8 +102,8 @@ app.controller('AppController', function( ImageWriterService, AnalyticsService, DriveSelectorService, - WindowProgressService, - NotificationService + OSWindowProgressService, + OSNotificationService ) { let self = this; this.selection = SelectionStateModel; @@ -128,7 +130,7 @@ app.controller('AppController', function( NotifierService.subscribe($scope, 'image-writer:state', function(state) { AnalyticsService.log(`Progress (${state.type}): ${state.progress}% at ${state.speed} MB/s`); - WindowProgressService.set(state.progress); + OSWindowProgressService.set(state.progress); }); this.scanner.start(2000).on('error', dialog.showError).on('scan', function(drives) { @@ -257,15 +259,15 @@ app.controller('AppController', function( self.success = success; if (self.success) { - NotificationService.send('Success!', 'Your flash is complete'); + OSNotificationService.send('Success!', 'Your flash is complete'); AnalyticsService.logEvent('Done'); $state.go('success'); } else { - NotificationService.send('Oops!', 'Looks like your flash has failed'); + OSNotificationService.send('Oops!', 'Looks like your flash has failed'); AnalyticsService.logEvent('Flash error'); } }) .catch(dialog.showError) - .finally(WindowProgressService.clear); + .finally(OSWindowProgressService.clear); }; }); diff --git a/lib/browser/modules/image-writer.js b/lib/browser/modules/image-writer.js index 2e8319a9..71ff02b1 100644 --- a/lib/browser/modules/image-writer.js +++ b/lib/browser/modules/image-writer.js @@ -30,10 +30,10 @@ if (window.mocha) { } require('../models/settings'); -require('./notifier'); +require('../utils/notifier/notifier'); const imageWriter = angular.module('Etcher.image-writer', [ 'Etcher.Models.Settings', - 'Etcher.notifier' + 'Etcher.Utils.Notifier' ]); imageWriter.service('ImageWriterService', function($q, $timeout, SettingsModel, NotifierService) { diff --git a/lib/browser/utils/dropzone/directives/dropzone.js b/lib/browser/os/dropzone/directives/dropzone.js similarity index 93% rename from lib/browser/utils/dropzone/directives/dropzone.js rename to lib/browser/os/dropzone/directives/dropzone.js index a2bb9350..7c4183b0 100644 --- a/lib/browser/utils/dropzone/directives/dropzone.js +++ b/lib/browser/os/dropzone/directives/dropzone.js @@ -31,13 +31,13 @@ const _ = require('lodash'); * @returns {Object} directive * * @example - *
Drag a file here
+ *
Drag a file here
*/ module.exports = function($timeout) { return { restrict: 'A', scope: { - dropzone: '&' + osDropzone: '&' }, link: function(scope, element) { const domElement = element[0]; @@ -55,7 +55,7 @@ module.exports = function($timeout) { // Safely bring this to the word of Angular $timeout(function() { - scope.dropzone({ + scope.osDropzone({ // Pass the filename as a named // parameter called `$file` diff --git a/lib/browser/utils/dropzone/dropzone.js b/lib/browser/os/dropzone/dropzone.js similarity index 80% rename from lib/browser/utils/dropzone/dropzone.js rename to lib/browser/os/dropzone/dropzone.js index a6d41600..bbb04ba5 100644 --- a/lib/browser/utils/dropzone/dropzone.js +++ b/lib/browser/os/dropzone/dropzone.js @@ -17,9 +17,9 @@ 'use strict'; /** - * @module Etcher.Utils.Dropzone + * @module Etcher.OS.Dropzone */ const angular = require('angular'); -const Dropzone = angular.module('Etcher.Utils.Dropzone', []); -Dropzone.directive('dropzone', require('./directives/dropzone')); +const OSDropzone = angular.module('Etcher.OS.Dropzone', []); +OSDropzone.directive('osDropzone', require('./directives/dropzone')); diff --git a/lib/browser/os/notification/notification.js b/lib/browser/os/notification/notification.js new file mode 100644 index 00000000..1f0a70f4 --- /dev/null +++ b/lib/browser/os/notification/notification.js @@ -0,0 +1,28 @@ +/* + * 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'; + +/** + * @module Etcher.OS.Notification + * + * The purpose of this module is to provide an easy way + * to send desktop notifications. + */ + +const angular = require('angular'); +const OSNotification = angular.module('Etcher.OS.Notification', []); +OSNotification.service('OSNotificationService', require('./services/notification')); diff --git a/lib/browser/modules/notification.js b/lib/browser/os/notification/services/notification.js similarity index 79% rename from lib/browser/modules/notification.js rename to lib/browser/os/notification/services/notification.js index 4ba982ac..844b913e 100644 --- a/lib/browser/modules/notification.js +++ b/lib/browser/os/notification/services/notification.js @@ -16,16 +16,9 @@ 'use strict'; -/** - * @module Etcher.notification - */ - -const angular = require('angular'); const electron = require('electron'); -const app = electron.remote.app; -const notification = angular.module('Etcher.notification', []); -notification.service('NotificationService', function() { +module.exports = function() { /** * @summary Send a notification @@ -42,7 +35,7 @@ notification.service('NotificationService', function() { * @returns {Object} HTML5 notification object * * @example - * const notification = NotificationService.send('Hello', 'Foo Bar Bar'); + * const notification = OSNotificationService.send('Hello', 'Foo Bar Bar'); * notification.onclick = function() { * console.log('The notification has been clicked'); * }; @@ -50,8 +43,8 @@ notification.service('NotificationService', function() { this.send = function(title, body) { // `app.dock` is only defined in OS X - if (app.dock) { - app.dock.bounce(); + if (electron.remote.app.dock) { + electron.remote.app.dock.bounce(); } return new Notification(title, { @@ -59,4 +52,4 @@ notification.service('NotificationService', function() { }); }; -}); +}; diff --git a/lib/browser/utils/open-external/directives/open-external.js b/lib/browser/os/open-external/directives/open-external.js similarity index 91% rename from lib/browser/utils/open-external/directives/open-external.js rename to lib/browser/os/open-external/directives/open-external.js index b9ced94d..c79a993e 100644 --- a/lib/browser/utils/open-external/directives/open-external.js +++ b/lib/browser/os/open-external/directives/open-external.js @@ -27,14 +27,14 @@ const nodeOpen = require('open'); * * Example: * - * + * */ module.exports = function() { return { restrict: 'A', scope: { - openExternal: '@' + osOpenExternal: '@' }, link: function(scope, element) { @@ -59,10 +59,10 @@ module.exports = function() { // // See https://github.com/electron/electron/issues/5039 if (os.platform() === 'linux') { - return nodeOpen(scope.openExternal); + return nodeOpen(scope.osOpenExternal); } - shell.openExternal(scope.openExternal); + shell.openExternal(scope.osOpenExternal); }); } }; diff --git a/lib/browser/utils/open-external/open-external.js b/lib/browser/os/open-external/open-external.js similarity index 77% rename from lib/browser/utils/open-external/open-external.js rename to lib/browser/os/open-external/open-external.js index 821e707f..b27741cb 100644 --- a/lib/browser/utils/open-external/open-external.js +++ b/lib/browser/os/open-external/open-external.js @@ -17,9 +17,9 @@ 'use strict'; /** - * @module Etcher.Utils.OpenExternal + * @module Etcher.OS.OpenExternal */ const angular = require('angular'); -const OpenExternal = angular.module('Etcher.Utils.OpenExternal', []); -OpenExternal.directive('openExternal', require('./directives/open-external')); +const OSOpenExternal = angular.module('Etcher.OS.OpenExternal', []); +OSOpenExternal.directive('osOpenExternal', require('./directives/open-external')); diff --git a/lib/browser/utils/window-progress/services/window-progress.js b/lib/browser/os/window-progress/services/window-progress.js similarity index 95% rename from lib/browser/utils/window-progress/services/window-progress.js rename to lib/browser/os/window-progress/services/window-progress.js index be821c6a..32908735 100644 --- a/lib/browser/utils/window-progress/services/window-progress.js +++ b/lib/browser/os/window-progress/services/window-progress.js @@ -45,7 +45,7 @@ module.exports = function() { * @param {Number} percentage - percentage * * @example - * WindowProgressService.set(85); + * OSWindowProgressService.set(85); */ this.set = function(percentage) { if (percentage > 100 || percentage < 0) { @@ -61,7 +61,7 @@ module.exports = function() { * @public * * @example - * WindowProgressService.clear(); + * OSWindowProgressService.clear(); */ this.clear = function() { diff --git a/lib/browser/utils/window-progress/window-progress.js b/lib/browser/os/window-progress/window-progress.js similarity index 80% rename from lib/browser/utils/window-progress/window-progress.js rename to lib/browser/os/window-progress/window-progress.js index dfc6072c..c7b2c076 100644 --- a/lib/browser/utils/window-progress/window-progress.js +++ b/lib/browser/os/window-progress/window-progress.js @@ -17,7 +17,7 @@ 'use strict'; /** - * @module Etcher.Utils.WindowProgress + * @module Etcher.OS.WindowProgress * * The purpose of this module is to provide an easy way * to interact with the operating system's window progress @@ -25,5 +25,5 @@ */ const angular = require('angular'); -const WindowProgress = angular.module('Etcher.Utils.WindowProgress', []); -WindowProgress.service('WindowProgressService', require('./services/window-progress')); +const OSWindowProgress = angular.module('Etcher.OS.WindowProgress', []); +OSWindowProgress.service('OSWindowProgressService', require('./services/window-progress')); diff --git a/lib/browser/utils/notifier/notifier.js b/lib/browser/utils/notifier/notifier.js new file mode 100644 index 00000000..84e36eee --- /dev/null +++ b/lib/browser/utils/notifier/notifier.js @@ -0,0 +1,28 @@ +/* + * 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'; + +/** + * @module Etcher.Utils.Notifier + * + * The purpose of this module is to provide a safe way + * to emit and receive events from the $rootScope. + */ + +const angular = require('angular'); +const Notifier = angular.module('Etcher.Utils.Notifier', []); +Notifier.service('NotifierService', require('./services/notifier')); diff --git a/lib/browser/modules/notifier.js b/lib/browser/utils/notifier/services/notifier.js similarity index 89% rename from lib/browser/modules/notifier.js rename to lib/browser/utils/notifier/services/notifier.js index 7295a09f..118b3a18 100644 --- a/lib/browser/modules/notifier.js +++ b/lib/browser/utils/notifier/services/notifier.js @@ -16,19 +16,12 @@ 'use strict'; -/** - * @module Etcher.notifier - */ - -const angular = require('angular'); -const notifier = angular.module('Etcher.notifier', []); - /* * Based on: * http://www.codelord.net/2015/05/04/angularjs-notifying-about-changes-from-services-to-controllers/ */ -notifier.service('NotifierService', function($rootScope) { +module.exports = function($rootScope) { /** * @summary Safely subscribe to an event @@ -71,4 +64,4 @@ notifier.service('NotifierService', function($rootScope) { $rootScope.$emit(name, data); }; -}); +}; diff --git a/lib/browser/modules/path.js b/lib/browser/utils/path/filters/basename.js similarity index 83% rename from lib/browser/modules/path.js rename to lib/browser/utils/path/filters/basename.js index 4337aa00..6df56189 100644 --- a/lib/browser/modules/path.js +++ b/lib/browser/utils/path/filters/basename.js @@ -16,16 +16,9 @@ 'use strict'; -/** - * @module Etcher.path - */ - -const angular = require('angular'); const path = require('path'); -const pathModule = angular.module('Etcher.path', []); - -pathModule.filter('basename', function() { +module.exports = function() { /** * @summary Get the basename of a path @@ -39,4 +32,5 @@ pathModule.filter('basename', function() { * {{ '/foo/bar/baz' | basename }} */ return path.basename; -}); + +}; diff --git a/lib/browser/utils/path/path.js b/lib/browser/utils/path/path.js new file mode 100644 index 00000000..76717c92 --- /dev/null +++ b/lib/browser/utils/path/path.js @@ -0,0 +1,28 @@ +/* + * 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'; + +/** + * @module Etcher.Utils.Path + * + * The purpose of this module is to provide utilities + * to work with file paths. + */ + +const angular = require('angular'); +const Path = angular.module('Etcher.Utils.Path', []); +Path.filter('basename', require('./filters/basename')); diff --git a/lib/index.html b/lib/index.html index 00f758fd..1ecd95ab 100644 --- a/lib/index.html +++ b/lib/index.html @@ -21,7 +21,7 @@
- @@ -40,16 +40,16 @@ + os-open-external="https://etcher.io"> - IS AN OPEN SOURCE PROJECT BY + IS AN OPEN SOURCE PROJECT BY + os-open-external="https://resin.io"> diff --git a/lib/partials/main.html b/lib/partials/main.html index 5976bf43..a29ecde0 100644 --- a/lib/partials/main.html +++ b/lib/partials/main.html @@ -1,6 +1,6 @@
-
+
1 diff --git a/lib/scss/main.scss b/lib/scss/main.scss index 4ab621bd..a1c05bf7 100644 --- a/lib/scss/main.scss +++ b/lib/scss/main.scss @@ -99,7 +99,7 @@ body { margin: 0 13px; } - [open-external]:hover { + [os-open-external]:hover { color: lighten($color-disabled, 5%); text-decoration: underline; } diff --git a/tests/browser/utils/dropzone.spec.js b/tests/browser/os/dropzone.spec.js similarity index 82% rename from tests/browser/utils/dropzone.spec.js rename to tests/browser/os/dropzone.spec.js index e671e017..19de54c3 100644 --- a/tests/browser/utils/dropzone.spec.js +++ b/tests/browser/os/dropzone.spec.js @@ -19,13 +19,13 @@ const m = require('mochainon'); const angular = require('angular'); require('angular-mocks'); -require('../../../lib/browser/utils/dropzone/dropzone'); +require('../../../lib/browser/os/dropzone/dropzone'); -describe('Browser: Dropzone', function() { +describe('Browser: OSDropzone', function() { - beforeEach(angular.mock.module('Etcher.Utils.Dropzone')); + beforeEach(angular.mock.module('Etcher.OS.Dropzone')); - describe('dropzone', function() { + describe('osDropzone', function() { let $compile; let $rootScope; @@ -43,7 +43,7 @@ describe('Browser: Dropzone', function() { done(); }; - const element = $compile('
Drop a file here
')($rootScope); + const element = $compile('
Drop a file here
')($rootScope); $rootScope.$digest(); element[0].ondrop({ @@ -67,7 +67,7 @@ describe('Browser: Dropzone', function() { done(); }; - const element = $compile('
Drop a file here
')($rootScope); + const element = $compile('
Drop a file here
')($rootScope); $rootScope.$digest(); element[0].ondrop({ diff --git a/tests/browser/utils/open-external.spec.js b/tests/browser/os/open-external.spec.js similarity index 80% rename from tests/browser/utils/open-external.spec.js rename to tests/browser/os/open-external.spec.js index 27c26556..de04060e 100644 --- a/tests/browser/utils/open-external.spec.js +++ b/tests/browser/os/open-external.spec.js @@ -22,13 +22,13 @@ const angular = require('angular'); const electron = require('electron'); const shell = electron.remote.require('shell'); require('angular-mocks'); -require('../../../lib/browser/utils/open-external/open-external'); +require('../../../lib/browser/os/open-external/open-external'); -describe('Browser: OpenExternal', function() { +describe('Browser: OSOpenExternal', function() { - beforeEach(angular.mock.module('Etcher.Utils.OpenExternal')); + beforeEach(angular.mock.module('Etcher.OS.OpenExternal')); - describe('openExternal', function() { + describe('osOpenExternal', function() { let $compile; let $rootScope; @@ -39,7 +39,7 @@ describe('Browser: OpenExternal', function() { })); it('should set the element cursor to pointer', function() { - const element = $compile('Resin.io')($rootScope); + const element = $compile('Resin.io')($rootScope); $rootScope.$digest(); m.chai.expect(element.css('cursor')).to.equal('pointer'); }); @@ -57,7 +57,7 @@ describe('Browser: OpenExternal', function() { it('should call Electron shell.openExternal with the attribute value', function() { const shellExternalStub = m.sinon.stub(shell, 'openExternal'); - const element = $compile('Resin.io')($rootScope); + const element = $compile('Resin.io')($rootScope); element.triggerHandler('click'); $rootScope.$digest(); m.chai.expect(shellExternalStub).to.have.been.calledWith('https://resin.io'); diff --git a/tests/browser/utils/window-progress.spec.js b/tests/browser/os/window-progress.spec.js similarity index 73% rename from tests/browser/utils/window-progress.spec.js rename to tests/browser/os/window-progress.spec.js index 7bde1c7e..9a8fd8f2 100644 --- a/tests/browser/utils/window-progress.spec.js +++ b/tests/browser/os/window-progress.spec.js @@ -19,18 +19,18 @@ const m = require('mochainon'); const angular = require('angular'); require('angular-mocks'); -require('../../../lib/browser/utils/window-progress/window-progress'); +require('../../../lib/browser/os/window-progress/window-progress'); -describe('Browser: WindowProgress', function() { +describe('Browser: OSWindowProgress', function() { - beforeEach(angular.mock.module('Etcher.Utils.WindowProgress')); + beforeEach(angular.mock.module('Etcher.OS.WindowProgress')); - describe('WindowProgressService', function() { + describe('OSWindowProgressService', function() { - let WindowProgressService; + let OSWindowProgressService; - beforeEach(angular.mock.inject(function(_WindowProgressService_) { - WindowProgressService = _WindowProgressService_; + beforeEach(angular.mock.inject(function(_OSWindowProgressService_) { + OSWindowProgressService = _OSWindowProgressService_; })); describe('given a stubbed current window', function() { @@ -38,7 +38,7 @@ describe('Browser: WindowProgress', function() { beforeEach(function() { this.setProgressBarSpy = m.sinon.spy(); - WindowProgressService.currentWindow = { + OSWindowProgressService.currentWindow = { setProgressBar: this.setProgressBarSpy }; }); @@ -46,29 +46,29 @@ describe('Browser: WindowProgress', function() { describe('.set()', function() { it('should translate 0-100 percentages to 0-1 ranges', function() { - WindowProgressService.set(85); + OSWindowProgressService.set(85); m.chai.expect(this.setProgressBarSpy).to.have.been.calledWith(0.85); }); it('should set 0 given 0', function() { - WindowProgressService.set(0); + OSWindowProgressService.set(0); m.chai.expect(this.setProgressBarSpy).to.have.been.calledWith(0); }); it('should set 1 given 100', function() { - WindowProgressService.set(100); + OSWindowProgressService.set(100); m.chai.expect(this.setProgressBarSpy).to.have.been.calledWith(1); }); it('should throw if given a percentage higher than 100', function() { m.chai.expect(function() { - WindowProgressService.set(101); + OSWindowProgressService.set(101); }).to.throw('Invalid window progress percentage: 101'); }); it('should throw if given a percentage less than 0', function() { m.chai.expect(function() { - WindowProgressService.set(-1); + OSWindowProgressService.set(-1); }).to.throw('Invalid window progress percentage: -1'); }); @@ -77,7 +77,7 @@ describe('Browser: WindowProgress', function() { describe('.clear()', function() { it('should set -1', function() { - WindowProgressService.clear(); + OSWindowProgressService.clear(); m.chai.expect(this.setProgressBarSpy).to.have.been.calledWith(-1); }); diff --git a/tests/browser/modules/notifier.spec.js b/tests/browser/utils/notifier.spec.js similarity index 92% rename from tests/browser/modules/notifier.spec.js rename to tests/browser/utils/notifier.spec.js index 8af60d63..3ca1e9a9 100644 --- a/tests/browser/modules/notifier.spec.js +++ b/tests/browser/utils/notifier.spec.js @@ -3,11 +3,11 @@ const m = require('mochainon'); const angular = require('angular'); require('angular-mocks'); -require('../../../lib/browser/modules/notifier'); +require('../../../lib/browser/utils/notifier/notifier'); describe('Browser: Notifier', function() { - beforeEach(angular.mock.module('Etcher.notifier')); + beforeEach(angular.mock.module('Etcher.Utils.Notifier')); describe('NotifierService', function() { diff --git a/tests/browser/modules/path.spec.js b/tests/browser/utils/path.spec.js similarity index 87% rename from tests/browser/modules/path.spec.js rename to tests/browser/utils/path.spec.js index 1664cb18..baef791b 100644 --- a/tests/browser/modules/path.spec.js +++ b/tests/browser/utils/path.spec.js @@ -4,11 +4,11 @@ const m = require('mochainon'); const angular = require('angular'); const os = require('os'); require('angular-mocks'); -require('../../../lib/browser/modules/path'); +require('../../../lib/browser/utils/path/path'); describe('Browser: Path', function() { - beforeEach(angular.mock.module('Etcher.path')); + beforeEach(angular.mock.module('Etcher.Utils.Path')); describe('BasenameFilter', function() {