-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(forms): write missing specs for editableDatepicker directive
- Loading branch information
Showing
3 changed files
with
47 additions
and
3 deletions.
There are no files selected for viewing
1 change: 0 additions & 1 deletion
1
src/scripts/angleGrinder/modules/forms/editableDatepicker.coffee
This file contains 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 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
45 changes: 45 additions & 0 deletions
45
tests/unit/angleGrinder/modules/forms/editableDatepickerSpec.coffee
This file contains 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 |
---|---|---|
@@ -0,0 +1,45 @@ | ||
describe "module: angleGrinder.forms", -> | ||
|
||
describe "directive: editableDatepicker", -> | ||
|
||
beforeEach module "angleGrinder.forms" | ||
|
||
$scope = null | ||
element = null | ||
|
||
beforeEach inject ($rootScope, $compile) -> | ||
$scope = $rootScope.$new() | ||
$scope.user = birth: new Date() | ||
|
||
element = angular.element """ | ||
<form editable-form name="testForm"> | ||
<span editable-datepicker="user.birth">{{user.birth | date}}</span> | ||
</form> | ||
""" | ||
$compile(element)($scope) | ||
$scope.$digest() | ||
|
||
describe "when the form is visible", -> | ||
|
||
beforeEach -> | ||
$scope.testForm.$show() | ||
$scope.$digest() | ||
|
||
editableScope = null | ||
beforeEach -> editableScope = element.find("[editable-datepicker]").scope() | ||
|
||
calendarButtonEl = null | ||
beforeEach -> calendarButtonEl = element.find("button i.icon-calendar") | ||
|
||
it "has a button for open the picker", -> | ||
expect(calendarButtonEl.length).to.eq 1 | ||
|
||
it "initially has closed calendar", -> | ||
expect(editableScope.opened).to.be.false | ||
|
||
describe "when `open calendar` button is clicked", -> | ||
|
||
beforeEach -> calendarButtonEl.click() | ||
|
||
it "opens the calendar", -> | ||
expect(editableScope.opened).to.be.true |