#46 Moved test cases into test folder

This commit is contained in:
mauriziovitale84
2016-05-09 17:24:09 +01:00
parent 3c7fa6e8a6
commit b1933a53f2
9 changed files with 80 additions and 142 deletions

View File

@@ -1,82 +0,0 @@
/**
* @license
* Copyright 2016 Alfresco Software, Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
System.register(['angular2/testing', 'angular2/core', 'angular2/http', 'angular2/http/testing', './upload.service'], function(exports_1, context_1) {
"use strict";
var __moduleName = context_1 && context_1.id;
var testing_1, core_1, http_1, testing_2, upload_service_1;
return {
setters:[
function (testing_1_1) {
testing_1 = testing_1_1;
},
function (core_1_1) {
core_1 = core_1_1;
},
function (http_1_1) {
http_1 = http_1_1;
},
function (testing_2_1) {
testing_2 = testing_2_1;
},
function (upload_service_1_1) {
upload_service_1 = upload_service_1_1;
}],
execute: function() {
testing_1.describe('AlfrescoUploadService', function () {
var injector, backend, mockBackend, httpService, service, options;
beforeEach(function () {
injector = core_1.Injector.resolveAndCreate([
http_1.HTTP_PROVIDERS,
testing_2.MockBackend,
core_1.provide(http_1.XHRBackend, { useClass: testing_2.MockBackend })
]);
mockBackend = injector.get(testing_2.MockBackend);
backend = injector.get(http_1.XHRBackend);
httpService = injector.get(http_1.Http);
options = {
url: '',
withCredentials: true,
authToken: btoa('fakeadmin:fakeadmin'),
authTokenPrefix: 'Basic',
fieldName: 'fakeFileData',
formFields: {
siteid: 'fakeSite',
containerid: 'fakeFolder'
}
};
service = new upload_service_1.UploadService(options);
});
testing_1.it('should make XHR request', function () {
var xhr = {
open: jasmine.createSpy('open'),
upload: jasmine.createSpy('upload'),
send: jasmine.createSpy('send'),
setRequestHeader: jasmine.createSpy('setRequestHeader')
};
XMLHttpRequest = jasmine.createSpy('XMLHttpRequest');
XMLHttpRequest.and.callFake(function () {
return xhr;
});
var filesFake = [{ name: 'fake-name', size: 10 }];
service.addToQueue(filesFake);
expect(xhr.open).toHaveBeenCalled();
});
});
}
}
});
//# sourceMappingURL=upload.service.spec.js.map

View File

@@ -1 +0,0 @@
{"version":3,"file":"upload.service.spec.js","sourceRoot":"","sources":["upload.service.spec.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;;;;;;;;;;;;;;;;;;;;;;;YAQH,kBAAQ,CAAC,uBAAuB,EAAE;gBAC9B,IAAI,QAAQ,EACR,OAAO,EACP,WAAW,EACX,WAAW,EACX,OAAO,EACP,OAAO,CAAC;gBAEZ,UAAU,CAAC;oBACP,QAAQ,GAAG,eAAQ,CAAC,gBAAgB,CAAC;wBACjC,qBAAc;wBACd,qBAAW;wBACX,cAAO,CAAC,iBAAU,EAAE,EAAC,QAAQ,EAAE,qBAAW,EAAC,CAAC;qBAC/C,CAAC,CAAC;oBAEH,WAAW,GAAG,QAAQ,CAAC,GAAG,CAAC,qBAAW,CAAC,CAAC;oBACxC,OAAO,GAAG,QAAQ,CAAC,GAAG,CAAC,iBAAU,CAAC,CAAC;oBACnC,WAAW,GAAG,QAAQ,CAAC,GAAG,CAAC,WAAI,CAAC,CAAC;oBAGjC,OAAO,GAAG;wBACN,GAAG,EAAE,EAAE;wBACP,eAAe,EAAE,IAAI;wBACrB,SAAS,EAAE,IAAI,CAAC,qBAAqB,CAAC;wBACtC,eAAe,EAAE,OAAO;wBACxB,SAAS,EAAE,cAAc;wBACzB,UAAU,EAAE;4BACR,MAAM,EAAE,UAAU;4BAClB,WAAW,EAAE,YAAY;yBAC5B;qBACJ,CAAC;oBACF,OAAO,GAAG,IAAI,8BAAa,CAAC,OAAO,CAAC,CAAC;gBACzC,CAAC,CAAC,CAAC;gBAEH,YAAE,CAAC,yBAAyB,EAAE;oBAE1B,IAAI,GAAG,GAAG;wBACN,IAAI,EAAE,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC;wBAC/B,MAAM,EAAE,OAAO,CAAC,SAAS,CAAC,QAAQ,CAAC;wBACnC,IAAI,EAAE,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC;wBAC/B,gBAAgB,EAAE,OAAO,CAAC,SAAS,CAAC,kBAAkB,CAAC;qBAC1D,CAAC;oBAEF,cAAc,GAAG,OAAO,CAAC,SAAS,CAAC,gBAAgB,CAAC,CAAC;oBACrD,cAAc,CAAC,GAAG,CAAC,QAAQ,CAAC;wBACxB,MAAM,CAAC,GAAG,CAAC;oBACf,CAAC,CAAC,CAAC;oBAEH,IAAI,SAAS,GAAG,CAAC,EAAC,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,EAAE,EAAC,CAAC,CAAC;oBAChD,OAAO,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;oBAE9B,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,gBAAgB,EAAE,CAAC;gBACxC,CAAC,CAAC,CAAC;YAIP,CAAC,CAAC,CAAC"}

View File

@@ -1,79 +0,0 @@
/**
* @license
* Copyright 2016 Alfresco Software, Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {it, describe} from 'angular2/testing';
import {provide, Injector} from 'angular2/core';
import {Http, HTTP_PROVIDERS, XHRBackend, Response, ResponseOptions} from 'angular2/http';
import {MockBackend} from 'angular2/http/testing';
import {UploadService} from './upload.service';
describe('AlfrescoUploadService', () => {
let injector,
backend,
mockBackend,
httpService,
service,
options;
beforeEach(() => {
injector = Injector.resolveAndCreate([
HTTP_PROVIDERS,
MockBackend,
provide(XHRBackend, {useClass: MockBackend})
]);
mockBackend = injector.get(MockBackend);
backend = injector.get(XHRBackend);
httpService = injector.get(Http);
options = {
url: 'http://mockUpload',
withCredentials: true,
authToken: btoa('fakeadmin:fakeadmin'),
authTokenPrefix: 'Basic',
fieldName: 'fakeFileData',
formFields: {
siteid: 'fakeSite',
containerid: 'fakeFolder'
}
};
service = new UploadService(options);
});
it('should make XHR request', () => {
var xhr = {
open: jasmine.createSpy('open'),
upload: jasmine.createSpy('upload'),
send: jasmine.createSpy('send'),
setRequestHeader: jasmine.createSpy('setRequestHeader')
};
XMLHttpRequest = jasmine.createSpy('XMLHttpRequest');
XMLHttpRequest.and.callFake(function () {
return xhr;
});
let filesFake = [{name: 'fake-name', size: 10}];
service.addToQueue(filesFake);
expect(xhr.open).toHaveBeenCalled();
});
});