Skip to content

Commit adb446b

Browse files
committed
Add more test for set/getValidMethod and update demo page link to API.md
1 parent 071f735 commit adb446b

2 files changed

Lines changed: 55 additions & 0 deletions

File tree

index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
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 -->

test/unit/setgetValidMethodSpec.js

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
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+
});

0 commit comments

Comments
 (0)