From 5ded0a37080c14fe86689d142fbc076e82c89028 Mon Sep 17 00:00:00 2001 From: Max Lynch Date: Thu, 23 Jan 2014 12:25:44 -0600 Subject: [PATCH] Scroll delegate unit tests --- .../delegates/ionicScrollDelegate.unit.js | 69 +++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 js/ext/angular/test/service/delegates/ionicScrollDelegate.unit.js diff --git a/js/ext/angular/test/service/delegates/ionicScrollDelegate.unit.js b/js/ext/angular/test/service/delegates/ionicScrollDelegate.unit.js new file mode 100644 index 0000000000..25b1668f68 --- /dev/null +++ b/js/ext/angular/test/service/delegates/ionicScrollDelegate.unit.js @@ -0,0 +1,69 @@ +describe('Ionic ScrollDelegate Service', function() { + var del, rootScope, compile, timeout, document; + + beforeEach(module('ionic')); + + beforeEach(inject(function($ionicScrollDelegate, $rootScope, $timeout, $compile, $document) { + del = $ionicScrollDelegate; + document = $document; + rootScope = $rootScope; + timeout = $timeout; + compile = $compile; + })); + + it('Should register', function() { + spyOn(del, 'register'); + + var scope = rootScope.$new(); + var el = compile('')(scope); + + expect(del.register).toHaveBeenCalled(); + }); + + it('Should get scroll view', function() { + var scope = rootScope.$new(); + var el = compile('')(scope); + var sv = del.getScrollView(scope); + expect(sv).not.toBe(undefined); + }); + + it('Should scroll top', function() { + spyOn(del, 'register'); + + var scope = rootScope.$new(); + var el = compile('')(scope); + + var sv = del.getScrollView(scope); + + var v = sv.getValues(); + + expect(v.top).toBe(100); + + del.scrollTop(); + + expect(v.top).toBe(100); + }); + + xit('Should scroll bottom', function() { + spyOn(del, 'register'); + + var scope = rootScope.$new(); + var el = compile('
')(scope); + + var sv = del.getScrollView(scope); + timeout.flush(); + sv.resize(); + + var v = sv.getValues(); + + + expect(v.top).toBe(100); + + + console.log(sv.getScrollMax()); + del.scrollBottom(); + + expect(v.top).toBe(100); + }); +}); +