This repository was archived by the owner on Dec 3, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 124
Allow empty labels, move state CSS class to outer div. #54
Open
adamdicarlo
wants to merge
2
commits into
cgarvis:master
Choose a base branch
from
newrelic-forks:newrelic
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,10 @@ | ||
describe('Toggle Switch', function() { | ||
var $scope, $compile; | ||
var $scope, $compile, isolateScope; | ||
|
||
var baseTemplate = '<toggle-switch ng-model="switchState">\n</toggle-switch>'; | ||
var emptyOnLabelTemplate = '<toggle-switch ng-model="switchState" on-label="">\n</toggle-switch>'; | ||
var emptyOffLabelTemplate = '<toggle-switch ng-model="switchState" off-label="">\n</toggle-switch>'; | ||
var emptyKnobLabelTemplate = '<toggle-switch ng-model="switchState" knob-label="">\n</toggle-switch>'; | ||
var onLabelTemplate = '<toggle-switch ng-model="switchState" on-label="CUSTOM-ON">\n</toggle-switch>'; | ||
var offLabelTemplate = '<toggle-switch ng-model="switchState" off-label="CUSTOM-OFF">\n</toggle-switch>'; | ||
var knobLabelTemplate = '<toggle-switch ng-model="switchState" knob-label="CUSTOM">\n</toggle-switch>'; | ||
|
@@ -22,6 +25,7 @@ describe('Toggle Switch', function() { | |
var elm = angular.element(template); | ||
$compile(elm)(scope); | ||
scope.$apply(); | ||
isolateScope = elm.isolateScope(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why the need for the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. to keep the |
||
return elm; | ||
} | ||
|
||
|
@@ -96,6 +100,13 @@ describe('Toggle Switch', function() { | |
}); | ||
}); | ||
|
||
describe('with an empty `on-label`', function() { | ||
it('sets the label empty', function() { | ||
var elm = compileDirective(emptyOnLabelTemplate, $scope); | ||
expect(isolateScope.onLabel).toEqual(''); | ||
}); | ||
}); | ||
|
||
describe('when there is a custom `off-label`', function () { | ||
// @TODO: figure out how to deal with html in Angular 1.2 | ||
//describe('is html', function() { | ||
|
@@ -113,13 +124,27 @@ describe('Toggle Switch', function() { | |
}); | ||
}); | ||
|
||
describe('with an empty `off-label`', function() { | ||
it('sets the label empty', function() { | ||
var elm = compileDirective(emptyOffLabelTemplate, $scope); | ||
expect(isolateScope.offLabel).toEqual(''); | ||
}); | ||
}); | ||
|
||
describe('when there is a custom `knob-label`', function () { | ||
it('sets the on label', function() { | ||
var elm = compileDirective(knobLabelTemplate, $scope); | ||
expect(elm.text()).toContain('CUSTOM'); | ||
}); | ||
}); | ||
|
||
describe('with an empty `knob-label`', function() { | ||
it('sets the label empty', function() { | ||
var elm = compileDirective(emptyKnobLabelTemplate, $scope); | ||
expect(isolateScope.knobLabel).toEqual(''); | ||
}); | ||
}); | ||
|
||
describe('when toggle is disabled', function() { | ||
it('ngModel does not change on click', function() { | ||
$scope.switchState = true; | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a specific reason you switched these? If I remember correctly, there is a reason we do this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes; because it was impossible to specify an empty label via a directive attribute.
You can try the new tests for empty labels on master and watch 'em fail.