forked from Textalk/angular-schema-form-datepicker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtests.js
63 lines (51 loc) · 1.78 KB
/
tests.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/* jshint expr: true */
chai.should();
describe('Schema form', function() {
describe('directive', function() {
beforeEach(module('templates'));
beforeEach(module('schemaForm'));
beforeEach(
//We don't need no sanitation. We don't need no though control.
module(function($sceProvider) {
$sceProvider.enabled(false);
})
);
it('should use datepicker directive when format is "date"', function() {
//Mock pickadate
$.fn.pickadate = sinon.stub().returns({
set: sinon.stub(),
get: sinon.stub().returns('get')
});
$.fn.pickadate.defaults = {format: 'yyyy-mm-dd'};
inject(function($compile, $rootScope) {
var scope = $rootScope.$new();
scope.person = {partee: '2014-01-01'};
scope.schema = {
type: 'object',
properties: {
partee: {
title: 'Parteeeeee',
type: 'string',
format: 'date'
}
}
};
scope.form = [{
key: 'partee',
maxDate: new Date(),
minDate: '2014-02-13',
}];
var tmpl = angular
.element('<form sf-schema="schema" sf-form="form" sf-model="person"></form>');
$compile(tmpl)(scope);
$rootScope.$apply();
tmpl.children().length.should.be.equal(1);
tmpl.children().eq(0).children().eq(0).is('div').should.be.true;
tmpl.children().eq(0).children().eq(0).find('input[pick-a-date]').length.should.ok;
tmpl.children().eq(0).children().eq(0).find('input[pick-a-date]').attr('max-date').should.be.ok;
tmpl.children().eq(0).children().eq(0).find('input[pick-a-date]').attr('min-date').should.be.ok;
$.fn.pickadate.should.have.beenCalled;
});
});
});
});