Skip to content
This repository was archived by the owner on Sep 8, 2020. It is now read-only.

refactor(tests): tweak tests to support jquery-ui v1.11 #220

Merged
merged 5 commits into from
Jul 7, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
],
"dependencies": {
"angular": "~1.2.x",
"jquery-ui": ">=1.9 <1.11"
"jquery-ui": ">=1.9"
},
"devDependencies": {
"angular-mocks": "~1.2.x",
Expand Down
3 changes: 2 additions & 1 deletion test/karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ module.exports = function(config) {
'src/sortable.js',
'test/sortable.test-helper.js',
'test/sortable.test-directives.js',
'test/*.spec.js'
'test/*.spec.js',
'test/sortable.tests.css'
]),


Expand Down
63 changes: 0 additions & 63 deletions test/sortable.e2e.callbacks.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,69 +105,6 @@ describe('uiSortable', function() {
});
});

it('should cancel sorting of nodes that contain "Two"', function() {
inject(function($compile, $rootScope) {
var elementTop, elementBottom;
elementTop = $compile('<ul ui-sortable="opts" class="cross-sortable" ng-model="itemsTop"><li ng-repeat="item in itemsTop" id="s-top-{{$index}}">{{ item }}</li></ul>')($rootScope);
elementBottom = $compile('<ul ui-sortable="opts" class="cross-sortable" ng-model="itemsBottom"><li ng-repeat="item in itemsBottom" id="s-bottom-{{$index}}">{{ item }}</li></ul>')($rootScope);
$rootScope.$apply(function() {
$rootScope.itemsTop = ['Top One', 'Top Two', 'Top Three'];
$rootScope.itemsBottom = ['Bottom One', 'Bottom Two', 'Bottom Three'];
$rootScope.opts = {
connectWith: '.cross-sortable',
update: function(e, ui) {
if (ui.item.scope() &&
(typeof ui.item.scope().item === 'string') &&
ui.item.scope().item.indexOf('Two') >= 0) {
ui.item.sortable.cancel();
}
}
};
});

host.append(elementTop).append(elementBottom);

var li1 = elementTop.find(':eq(1)');
var li2 = elementBottom.find(':eq(0)');
var dy = EXTRA_DY_PERCENTAGE * li1.outerHeight() + (li2.position().top - li1.position().top);
li1.simulate('drag', { dy: dy });
expect($rootScope.itemsTop).toEqual(['Top One', 'Top Two', 'Top Three']);
expect($rootScope.itemsBottom).toEqual(['Bottom One', 'Bottom Two', 'Bottom Three']);
expect($rootScope.itemsTop).toEqual(listContent(elementTop));
expect($rootScope.itemsBottom).toEqual(listContent(elementBottom));

li1 = elementBottom.find(':eq(1)');
li2 = elementTop.find(':eq(1)');
dy = -EXTRA_DY_PERCENTAGE * li1.outerHeight() - (li1.position().top - li2.position().top);
li1.simulate('drag', { dy: dy });
expect($rootScope.itemsTop).toEqual(['Top One', 'Top Two', 'Top Three']);
expect($rootScope.itemsBottom).toEqual(['Bottom One', 'Bottom Two', 'Bottom Three']);
expect($rootScope.itemsTop).toEqual(listContent(elementTop));
expect($rootScope.itemsBottom).toEqual(listContent(elementBottom));

li1 = elementTop.find(':eq(0)');
li2 = elementBottom.find(':eq(0)');
dy = EXTRA_DY_PERCENTAGE * li1.outerHeight() + (li2.position().top - li1.position().top);
li1.simulate('drag', { dy: dy });
expect($rootScope.itemsTop).toEqual(['Top Two', 'Top Three']);
expect($rootScope.itemsBottom).toEqual(['Bottom One', 'Top One', 'Bottom Two', 'Bottom Three']);
expect($rootScope.itemsTop).toEqual(listContent(elementTop));
expect($rootScope.itemsBottom).toEqual(listContent(elementBottom));

li1 = elementBottom.find(':eq(1)');
li2 = elementTop.find(':eq(1)');
dy = -EXTRA_DY_PERCENTAGE * li1.outerHeight() - (li1.position().top - li2.position().top);
li1.simulate('drag', { dy: dy });
expect($rootScope.itemsTop).toEqual(['Top Two', 'Top One', 'Top Three']);
expect($rootScope.itemsBottom).toEqual(['Bottom One', 'Bottom Two', 'Bottom Three']);
expect($rootScope.itemsTop).toEqual(listContent(elementTop));
expect($rootScope.itemsBottom).toEqual(listContent(elementBottom));

$(elementTop).remove();
$(elementBottom).remove();
});
});

it('should update model from update() callback', function() {
inject(function($compile, $rootScope) {
var element, logsElement;
Expand Down
Loading