mirror of
https://github.com/frappe/air-datepicker.git
synced 2026-01-14 11:01:22 +08:00
add positions test to options.js
This commit is contained in:
parent
5601e8dc4a
commit
e8ef4364ab
@ -17,6 +17,12 @@
|
|||||||
|
|
||||||
<script type="text/javascript" src="specs/options.js"></script>
|
<script type="text/javascript" src="specs/options.js"></script>
|
||||||
<script type="text/javascript" src="specs/static-methods.js"></script>
|
<script type="text/javascript" src="specs/static-methods.js"></script>
|
||||||
|
<style type="text/css">
|
||||||
|
/* Remove transitions to test position options*/
|
||||||
|
.datepicker {
|
||||||
|
transition: none !important;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="container"></div>
|
<div id="container"></div>
|
||||||
|
|||||||
@ -289,5 +289,62 @@ describe('Options', function () {
|
|||||||
})
|
})
|
||||||
|
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('position', function () {
|
||||||
|
var iDims, dpDims,
|
||||||
|
offset;
|
||||||
|
|
||||||
|
function prepare (position) {
|
||||||
|
dp = $input.datepicker({position: position}).data('datepicker');
|
||||||
|
$input.focus();
|
||||||
|
|
||||||
|
iDims = {
|
||||||
|
width: $input.outerWidth(),
|
||||||
|
height: $input.outerHeight(),
|
||||||
|
left: $input.offset().left,
|
||||||
|
top: $input.offset().top
|
||||||
|
};
|
||||||
|
|
||||||
|
dpDims = {
|
||||||
|
width: dp.$datepicker.outerWidth(),
|
||||||
|
height: dp.$datepicker.outerHeight(),
|
||||||
|
left: dp.$datepicker.offset().left,
|
||||||
|
top: dp.$datepicker.offset().top
|
||||||
|
};
|
||||||
|
|
||||||
|
offset = dp.opts.offset;
|
||||||
|
}
|
||||||
|
|
||||||
|
it('should set `bottom left` position', function () {
|
||||||
|
prepare('bottom left');
|
||||||
|
|
||||||
|
assert.equal(iDims.top + iDims.height + offset, dpDims.top);
|
||||||
|
assert.equal(iDims.left, dpDims.left);
|
||||||
|
});
|
||||||
|
it('should set `top right` position', function () {
|
||||||
|
prepare('top right');
|
||||||
|
|
||||||
|
assert.equal(iDims.top, dpDims.top + dpDims.height + offset);
|
||||||
|
assert.equal(iDims.left + iDims.width, dpDims.left + dpDims.width);
|
||||||
|
});
|
||||||
|
it('should set `right bottom` position', function () {
|
||||||
|
prepare('right bottom');
|
||||||
|
|
||||||
|
assert.equal(iDims.left + iDims.width + offset, dpDims.left);
|
||||||
|
assert.equal(iDims.top + iDims.height, dpDims.top + dpDims.height);
|
||||||
|
});
|
||||||
|
it('should set `left center` position', function () {
|
||||||
|
prepare('left center');
|
||||||
|
|
||||||
|
assert.equal(iDims.left - offset, dpDims.left + dpDims.width);
|
||||||
|
assert.equal(iDims.top + iDims.height/2, dpDims.top + dpDims.height/2);
|
||||||
|
});
|
||||||
|
it('should set `bottom center` position', function () {
|
||||||
|
prepare('bottom center');
|
||||||
|
|
||||||
|
assert.equal(iDims.top + iDims.height + offset, dpDims.top);
|
||||||
|
assert.equal(iDims.left + iDims.width/2, dpDims.left + dpDims.width/2);
|
||||||
|
})
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user