Skip to content

Commit

Permalink
chore(forms): write missing specs for editableDatepicker directive
Browse files Browse the repository at this point in the history
  • Loading branch information
lucassus committed Oct 23, 2014
1 parent 85b82bb commit 3150263
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
forms = angular.module("angleGrinder.forms")

# TODO spec it
# x-editable wrapper for date picker with calendar button
forms.directive "editableDatepicker", [
"editableDirectiveFactory", (editableDirectiveFactory) ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ describe "module: angleGrinder.forms", ->
$scope = $rootScope.$new()

$scope.roles = [
{ id: "guest", name: "Guest" }
{ id: "guest", name: "Guest" }
{ id: "moderator", name: "Moderator" }
{ id: "admin", name: "Admin" }
{ id: "admin", name: "Admin" }
]
$scope.user = role: "guest"

Expand Down
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

0 comments on commit 3150263

Please sign in to comment.