Skip to content
This repository has been archived by the owner on Sep 5, 2024. It is now read-only.

Commit

Permalink
fix(interimElement): Removed unnecessary resolve fallback values
Browse files Browse the repository at this point in the history
Removed SHOW_CLOSED fallback that caused false, empty string or undefined in the resolved promise to become true

fixes #4094. fixes #4150. closes #4982.
  • Loading branch information
EladBezalel authored and ThomasBurleson committed Oct 8, 2015
1 parent d2140b1 commit eae9eea
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/components/dialog/dialog.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ describe('$mdDialog', function() {

container = angular.element(parent[0].querySelector('.md-dialog-container'));
expect(container.length).toBe(0);
expect(response).toBe(false);
expect(response).toBe(undefined);
}));
});

Expand Down
4 changes: 2 additions & 2 deletions src/components/toast/toast.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ describe('$mdToast service', function() {

$material.flushInterimElement();

expect(result).toBe(true);
expect(result).toBe(undefined);
expect(angular.isUndefined(fault)).toBe(true);

}));
Expand Down Expand Up @@ -269,7 +269,7 @@ describe('$mdToast service', function() {

$material.flushInterimElement();

expect(result).toBe(true);
expect(result).toBe(undefined);
expect(angular.isUndefined(fault)).toBe(true);

}));
Expand Down
9 changes: 4 additions & 5 deletions src/core/services/interimElement/interimElement.js
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,6 @@ function InterimElementProvider() {
$mdUtil, $mdCompiler, $mdTheming, $log ) {
return function createInterimElementService() {
var SHOW_CANCELLED = false;
var SHOW_CLOSED = true;

/*
* @ngdoc service
Expand Down Expand Up @@ -318,7 +317,7 @@ function InterimElementProvider() {
*
*/
function hide(reason, options) {
if ( !stack.length ) return $q.when(reason || SHOW_CLOSED);
if ( !stack.length ) return $q.when(reason);
options = options || {};

if (options.closeAll) {
Expand All @@ -334,7 +333,7 @@ function InterimElementProvider() {

function closeElement(interim) {
interim
.remove(reason || SHOW_CLOSED, false, options || { })
.remove(reason, false, options || { })
.catch(function( reason ) {
//$log.error("InterimElement.hide() error: " + reason );
return reason;
Expand All @@ -357,10 +356,10 @@ function InterimElementProvider() {
*/
function cancel(reason, options) {
var interim = stack.shift();
if ( !interim ) return $q.when(reason || SHOW_CANCELLED);
if ( !interim ) return $q.when(reason);

interim
.remove(reason || SHOW_CANCELLED, true, options || { })
.remove(reason, true, options || { })
.catch(function( reason ) {
//$log.error("InterimElement.cancel() error: " + reason );
return reason;
Expand Down
28 changes: 27 additions & 1 deletion src/core/services/interimElement/interimElement.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,7 @@ describe('$$interimElement service', function() {
}
}));

it('resolves the show promise', inject(function( ) {
it('resolves the show promise with string', inject(function( ) {
var resolved = false;

Service.show().then(function(arg) {
Expand All @@ -547,6 +547,32 @@ describe('$$interimElement service', function() {
expect(resolved).toBe(true);
}));

it('resolves the show promise with false', inject(function( ) {
var resolved = false;

Service.show().then(function(arg) {
expect(arg).toBe(false);
resolved = true;
});

Service.hide(false);

expect(resolved).toBe(true);
}));

it('resolves the show promise with undefined', inject(function( ) {
var resolved = false;

Service.show().then(function(arg) {
expect(arg).toBe(undefined);
resolved = true;
});

Service.hide();

expect(resolved).toBe(true);
}));

describe('captures and fails with ',function(){

it('internal exception during hide()', inject(function($q, $timeout) {
Expand Down

0 comments on commit eae9eea

Please sign in to comment.