From 529dde57b99a359025dbca59ab9a972b8ce74dee Mon Sep 17 00:00:00 2001 From: Andrew Henry Date: Wed, 4 Nov 2015 20:12:36 -0800 Subject: [PATCH] Added test for notification to CopyActionSpec --- platform/entanglement/src/actions/CopyAction.js | 10 +++++----- .../entanglement/test/actions/CopyActionSpec.js | 17 +++++++++-------- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/platform/entanglement/src/actions/CopyAction.js b/platform/entanglement/src/actions/CopyAction.js index 6df372b45c..abbc521077 100644 --- a/platform/entanglement/src/actions/CopyAction.js +++ b/platform/entanglement/src/actions/CopyAction.js @@ -65,15 +65,15 @@ define( is shown non-invasive banner notifications at the bottom of the screen. */ if (phase.toLowerCase() === 'preparing' && !this.dialog){ - this.dialog = self.dialogService.showBlockingMessage({ + this.dialog = this.dialogService.showBlockingMessage({ title: "Preparing to copy objects", unknownProgress: true, severity: "info", }); } else if (phase.toLowerCase() === "copying") { - self.dialogService.dismiss(); - if (!notification) { - this.notification = self.notificationService + this.dialogService.dismiss(); + if (!this.notification) { + this.notification = this.notificationService .notify({ title: "Copying objects", unknownProgress: false, @@ -111,7 +111,7 @@ define( }, function notification(notification){ - this.progress(notification.phase, notification.totalObjects, notification.processed); + self.progress(notification.phase, notification.totalObjects, notification.processed); } ); }; diff --git a/platform/entanglement/test/actions/CopyActionSpec.js b/platform/entanglement/test/actions/CopyActionSpec.js index 3fa4055f4c..ebedf066db 100644 --- a/platform/entanglement/test/actions/CopyActionSpec.js +++ b/platform/entanglement/test/actions/CopyActionSpec.js @@ -46,7 +46,8 @@ define( notification, dialogService, mockLog, - abstractComposePromise; + abstractComposePromise, + progress = {phase: "copying", totalObjects: 10, processed: 1}; beforeEach(function () { selectedObjectContextCapability = jasmine.createSpyObj( @@ -100,7 +101,7 @@ define( ); abstractComposePromise.then.andCallFake(function(success, error, notify){ - notify({phase: "copying", totalObjects: 10, processed: 10}); + notify(progress); success(); } ) @@ -115,23 +116,23 @@ define( .andReturn(locationServicePromise); dialogService = jasmine.createSpyObj('dialogService', - ['showBlockingMessage'] + ['showBlockingMessage', 'dismiss'] ); - dialogService.showBlockingMessage.andReturn(); + //dialogService.showBlockingMessage.andReturn(); notification = jasmine.createSpyObj('notification', ['dismiss', 'model'] ); - notification.dismiss.andReturn(); + //notification.dismiss.andReturn(); notificationService = jasmine.createSpyObj('notificationService', - ['notify'] + ['notify', 'info'] ); notificationService.notify.andReturn(notification); mockLog = jasmine.createSpyObj('log', ['error']); - mockLog.error.andReturn(); + //mockLog.error.andReturn(); copyService = new MockCopyService(); }); @@ -189,7 +190,7 @@ define( }); it("notifies the user of progress", function(){ - expect(copyAction.progress.calls.length).toBeGreaterThan(0) + expect(notificationService.info).toHaveBeenCalled(); }); });