mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Add directive spec to validate the dialog template is loaded on element click
This commit is contained in:
@@ -7,8 +7,9 @@ angular.module("admin.enterprises").directive 'termsAndConditionsWarning', ($com
|
||||
scope.hold_file_input_and_show_warning_modal = (event) ->
|
||||
event.preventDefault()
|
||||
scope.template = $compile($templateCache.get('admin/modals/terms_and_conditions_warning.html'))(scope)
|
||||
scope.template.dialog(DialogDefaults)
|
||||
scope.template.dialog('open')
|
||||
if scope.template.dialog
|
||||
scope.template.dialog(DialogDefaults)
|
||||
scope.template.dialog('open')
|
||||
scope.$apply()
|
||||
|
||||
element.bind 'click', scope.hold_file_input_and_show_warning_modal
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
describe "termsAndConditionsWarning", ->
|
||||
element = null
|
||||
templatecache = null
|
||||
|
||||
beforeEach ->
|
||||
module('admin.enterprises')
|
||||
|
||||
inject ($rootScope, $compile, $templateCache) ->
|
||||
templatecache = $templateCache
|
||||
el = angular.element("<input terms-and-conditions-warning=\"true\"></input>")
|
||||
element = $compile(el)($rootScope)
|
||||
$rootScope.$digest()
|
||||
|
||||
describe "terms and conditions warning", ->
|
||||
it "should load template", ->
|
||||
spyOn(templatecache, 'get')
|
||||
element.triggerHandler('click');
|
||||
expect(templatecache.get).toHaveBeenCalledWith('admin/modals/terms_and_conditions_warning.html')
|
||||
Reference in New Issue
Block a user