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

Commit 6fbde25

Browse files
committed
Merge pull request #161 from thgreasi/master
test(sortable.spec): add simple $apply test to increase code coverage.
2 parents 1a7e194 + 4dbb846 commit 6fbde25

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

test/sortable.spec.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@ describe('uiSortable', function() {
44

55
// Ensure the sortable angular module is loaded
66
beforeEach(module('ui.sortable'));
7+
beforeEach(module('ui.sortable.testHelper'));
8+
9+
var listContent;
10+
11+
beforeEach(inject(function (sortableTestHelper) {
12+
listContent = sortableTestHelper.listContent;
13+
}));
714

815
describe('Simple use', function() {
916

@@ -29,6 +36,24 @@ describe('uiSortable', function() {
2936
});
3037
});
3138

39+
it('should refresh sortable properly after an apply', function() {
40+
inject(function($compile, $rootScope, $timeout) {
41+
var element;
42+
var childScope = $rootScope.$new();
43+
element = $compile('<ul ui-sortable ng-model="items"><li ng-repeat="item in items">{{ item }}</li></ul>')(childScope);
44+
$rootScope.$apply(function() {
45+
childScope.items = ['One', 'Two', 'Three'];
46+
});
47+
48+
expect(function() {
49+
$timeout.flush();
50+
}).not.toThrow();
51+
52+
expect(childScope.items).toEqual(['One', 'Two', 'Three']);
53+
expect(childScope.items).toEqual(listContent(element));
54+
});
55+
});
56+
3257
it('should not refresh sortable if destroyed', function() {
3358
inject(function($compile, $rootScope, $timeout) {
3459
var element;

0 commit comments

Comments
 (0)