Matteo Scandolo | aaa733d | 2016-04-26 08:42:51 -0700 | [diff] [blame^] | 1 | /** |
| 2 | * © OpenCORD |
| 3 | * |
| 4 | * Created by teone on 3/24/16. |
| 5 | */ |
| 6 | |
| 7 | (function () { |
| 8 | 'use strict'; |
| 9 | |
| 10 | describe('The xos.helper module', function(){ |
| 11 | describe('The xos-smart-table component', () => { |
| 12 | |
| 13 | let spy, scope, isolatedScope, element; |
| 14 | |
| 15 | beforeEach(module('xos.helpers')); |
| 16 | |
| 17 | // mock the service |
| 18 | beforeEach(function(){ |
| 19 | module(function($provide){ |
| 20 | $provide.service('MockResource', function(){ |
| 21 | this.test = (msg) => console.log(msg); |
| 22 | this.query = jasmine.createSpy('add') |
| 23 | .and.returnValue({$promise: cb => { |
| 24 | console.log('------------------ CB ------------------'); |
| 25 | return cb([]); |
| 26 | }}); |
| 27 | }); |
| 28 | }); |
| 29 | }) |
| 30 | |
| 31 | beforeEach(inject(function ($compile, $rootScope, MockResource) { |
| 32 | scope = $rootScope.$new(); |
| 33 | |
| 34 | scope.config = { |
| 35 | resource: 'MockResource' |
| 36 | }; |
| 37 | |
| 38 | spy = MockResource; |
| 39 | // console.log(MockResource.query.toString(), spy.query.toString()); |
| 40 | |
| 41 | element = angular.element('<xos-smart-table config="config"></xos-smart-table>'); |
| 42 | $compile(element)(scope); |
| 43 | scope.$digest(); |
| 44 | isolatedScope = element.isolateScope().vm; |
| 45 | })); |
| 46 | |
| 47 | it('should query elements', () => { |
| 48 | |
| 49 | console.log(spy.query.toString()); |
| 50 | expect(spy.query).toHaveBeenCalled(); |
| 51 | }); |
| 52 | |
| 53 | }); |
| 54 | }); |
| 55 | })(); |