Skip to content

Commit 6a64e18

Browse files
committed
test for the new format of the datasource get method
1 parent 89f04c2 commit 6a64e18

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

test/BasicSetupSpec.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,21 +74,20 @@ describe('uiScroll', function () {
7474
describe('basic setup (new datasource get signature)', function () {
7575
var scrollSettings = {datasource: 'myNewEmptyDatasource'};
7676

77-
return;
7877
// this does not work because spy always return 0 for the number of parameters (spy.length)
7978
it('should call get on the datasource 2 times ', function () {
8079
var spy;
8180
inject(function (myNewEmptyDatasource) {
82-
spy = spyOn(myNewEmptyDatasource, 'get').and.callThrough();
81+
spy = spyOn(myNewEmptyDatasource, 'actualGet').and.callThrough();
8382
});
8483
runTest(scrollSettings,
8584
function () {
8685
expect(spy.calls.all().length).toBe(2);
8786
expect(spy.calls.all()[0].args.length).toBe(2);
8887
expect(spy.calls.all()[0].args[0].index).toBe(1);
8988
expect(spy.calls.all()[0].args[0].count).toBe(10);
90-
expect(spy.calls.all()[0].args.length).toBe(2);
91-
expect(spy.calls.all()[1].args[0]).index.toBe(-9);
89+
expect(spy.calls.all()[1].args.length).toBe(2);
90+
expect(spy.calls.all()[1].args[0].index).toBe(-9);
9291
expect(spy.calls.all()[1].args[0].count).toBe(10);
9392
}
9493
);

test/datasources.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,20 @@ angular.module('ui.scroll.test.datasources', [])
1212

1313
.factory('myNewEmptyDatasource', [
1414
'$log', '$timeout', '$rootScope', function () {
15-
return {
15+
16+
// another layer of indirection introduced by the actualGet
17+
// is a workaround for the jasmine issue #1007 https://github.com/jasmine/jasmine/issues/1007
18+
result = {
1619
get: function (descriptor, success) {
20+
result.actualGet(descriptor, success);
21+
},
22+
actualGet: function (descriptor, success) {
1723
success([]);
1824
}
1925
};
26+
27+
return result;
28+
2029
}
2130
])
2231

0 commit comments

Comments
 (0)