Skip to content

Commit 1693ab5

Browse files
committed
Added a test for datepicker
1 parent fd037a5 commit 1693ab5

File tree

3 files changed

+51
-2
lines changed

3 files changed

+51
-2
lines changed

examples/bootstrap-example.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<html ng-app="test">
33
<head>
44
<meta charset="utf-8">
5-
<title>Boostrap Schema Form example</title>
5+
<title>Bootstrap Schema Form example</title>
66
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css">
77
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap-theme.min.css">
88
<link rel="stylesheet" href="../bower_components/pickadate/lib/themes/classic.css">

karma.conf.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ module.exports = function(config) {
2020
'bower_components/tv4/tv4.js',
2121
'src/module.js',
2222
'src/services/*.js',
23-
'src/directives/**/*.js',
23+
'src/directives/*.js',
24+
'src/directives/decorators/bootstrap/*.js',
25+
'src/directives/decorators/bootstrap/datepicker/*.js',
2426
'src/**/*.html',
2527
'test/*.js'
2628
],

test/schema-form-test.js

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -805,6 +805,53 @@ describe('Schema form',function(){
805805
});
806806

807807

808+
it('should use datepicker directive when format is "date"',function(){
809+
810+
//Mock pickadate
811+
$.fn.pickadate = sinon.stub().returns({
812+
set: sinon.stub(),
813+
get: sinon.stub().returns('get')
814+
});
815+
$.fn.pickadate.defaults = { format: 'yyyy-mm-dd' };
816+
817+
inject(function($compile,$rootScope){
818+
var scope = $rootScope.$new();
819+
scope.person = { partee: '2014-01-01'};
820+
821+
scope.schema = {
822+
type: "object",
823+
properties: {
824+
partee: {
825+
title: "Parteeeeee",
826+
type: "string",
827+
format: "date"
828+
}
829+
}
830+
};
831+
832+
833+
scope.form = [{
834+
key:'partee',
835+
maxDate: new Date(),
836+
minDate: '2014-02-13',
837+
}];
838+
839+
var tmpl = angular.element('<form sf-schema="schema" sf-form="form" sf-model="person"></form>');
840+
841+
$compile(tmpl)(scope);
842+
$rootScope.$apply();
843+
tmpl.children().length.should.be.equal(1);
844+
tmpl.children().eq(0).is('div').should.be.true;
845+
tmpl.children().eq(0).find('input[pick-a-date]').length.should.ok;
846+
tmpl.children().eq(0).find('input[pick-a-date]').attr('max-date').should.be.ok;
847+
tmpl.children().eq(0).find('input[pick-a-date]').attr('min-date').should.be.ok;
848+
849+
$.fn.pickadate.should.have.beenCalled;
850+
851+
});
852+
});
853+
854+
808855
});
809856

810857

0 commit comments

Comments
 (0)