File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 6262 < li class ="active "> < a href ="# "> Home</ a > </ li >
6363 < li > < a href ="#getting_started "> Getting started</ a > </ li >
6464 < li > < a href ="#examples "> Examples</ a > </ li >
65+ < li > < a href ="https://github.com/huei90/angular-validation/blob/master/API.md "> API</ a > </ li >
6566 < li > < a href ="https://github.com/huei90/angular-validation/issues "> Report an issue</ a > </ li >
6667 </ ul >
6768 </ div > <!--/.nav-collapse -->
Original file line number Diff line number Diff line change 1+ 'use strict' ;
2+
3+ /* jasmine specs for provider go here */
4+
5+ describe ( 'provider' , function ( ) {
6+ var $rootScope ;
7+ var $compile ;
8+ var $scope ;
9+ var $timeout ;
10+ var element ;
11+ var validationProvider ;
12+ var myApp ;
13+
14+ beforeEach ( function ( ) {
15+ myApp = angular . module ( 'myApp' , [ 'validation' , 'validation.rule' ] )
16+ . config ( function ( $validationProvider ) {
17+ validationProvider = $validationProvider ;
18+ } ) ;
19+ return myApp ;
20+ } ) ;
21+
22+ beforeEach ( module ( 'myApp' ) ) ;
23+
24+ beforeEach ( inject ( function ( $injector ) {
25+ $rootScope = $injector . get ( '$rootScope' ) ;
26+ $compile = $injector . get ( '$compile' ) ;
27+ $scope = $rootScope . $new ( ) ;
28+ $timeout = $injector . get ( '$timeout' ) ;
29+
30+ // set validMethod submit
31+ validationProvider . setValidMethod ( 'submit' ) ;
32+
33+ element = $compile ( '<form name="Form"><input type="text" name="required" ng-model="required" validator="required"></form>' ) ( $scope ) ;
34+
35+
36+ } ) ) ;
37+
38+
39+ it ( 'set validMethod submit' , inject ( function ( ) {
40+
41+ $scope . $apply ( function ( ) {
42+ $scope . required = 'required' ;
43+ } ) ;
44+
45+ expect ( element . find ( 'p' ) [ 0 ] ) . toBeUndefined ( ) ;
46+
47+ validationProvider . validate ( $scope . Form ) ;
48+
49+ // this is important step
50+ $timeout . flush ( ) ;
51+
52+ expect ( element . find ( 'p' ) [ 0 ] ) . toBeDefined ( ) ;
53+ } ) ) ;
54+ } ) ;
You can’t perform that action at this time.
0 commit comments