|
| 1 | +/* eslint-env jasmine */ |
| 2 | + |
| 3 | +'use strict'; |
| 4 | + |
| 5 | +var angular = require('angular'); |
| 6 | + |
| 7 | +describe('get', function() { |
| 8 | + beforeEach(function() { |
| 9 | + var ngModule = angular.module('mockModule', []); |
| 10 | + require('./../ApiServiceProvider')(ngModule); |
| 11 | + }); |
| 12 | + |
| 13 | + beforeEach(angular.mock.module('mockModule')); |
| 14 | + |
| 15 | + var streamApiService, |
| 16 | + $httpBackend; |
| 17 | + beforeEach(angular.mock.inject(function(_streamApiService_, _$httpBackend_) { |
| 18 | + streamApiService = _streamApiService_; |
| 19 | + $httpBackend = _$httpBackend_; |
| 20 | + })); |
| 21 | + |
| 22 | + var streamApi; |
| 23 | + beforeEach(function() { |
| 24 | + streamApi = streamApiService.getInstance({url: 'https://foo'}); |
| 25 | + }); |
| 26 | + |
| 27 | + it('should make call by correct url with array of object IDs', function() { |
| 28 | + var requestedUrl = 'https://foo/attask/api/task?ID=12345678&ID=23456789&fields=*,projectID'; |
| 29 | + $httpBackend.expect('GET', requestedUrl) |
| 30 | + .respond(200); |
| 31 | + |
| 32 | + streamApi.get('task', ['12345678', '23456789'], ['*', 'projectID']); |
| 33 | + |
| 34 | + $httpBackend.flush(); |
| 35 | + }); |
| 36 | + |
| 37 | + it('should make call by correct url with single element in IDs array', function() { |
| 38 | + var requestedUrl = 'https://foo/attask/api/task?ID=12345678&fields=*,projectID'; |
| 39 | + $httpBackend.expect('GET', requestedUrl) |
| 40 | + .respond(200); |
| 41 | + |
| 42 | + streamApi.get('task', ['12345678'], ['*', 'projectID']); |
| 43 | + |
| 44 | + $httpBackend.flush(); |
| 45 | + }); |
| 46 | + |
| 47 | + it('should make call by correct url with string ID', function() { |
| 48 | + var requestedUrl = 'https://foo/attask/api/task?ID=12345678&fields=*,projectID'; |
| 49 | + $httpBackend.expect('GET', requestedUrl) |
| 50 | + .respond(200); |
| 51 | + |
| 52 | + streamApi.get('task', '12345678', ['*', 'projectID']); |
| 53 | + |
| 54 | + $httpBackend.flush(); |
| 55 | + }); |
| 56 | +}); |
0 commit comments