mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-31 17:38:48 +00:00
#46 upload component Unit test
This commit is contained in:
0
ng2-components/ng2-alfresco-upload/src/services/upload.service.spec.d.ts
vendored
Normal file
0
ng2-components/ng2-alfresco-upload/src/services/upload.service.spec.d.ts
vendored
Normal file
@@ -0,0 +1,72 @@
|
||||
/**
|
||||
* @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: 'http://mockUpload',
|
||||
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 return true if is a file', function () {
|
||||
var filesFake = [{ name: 'fake-name', size: 0 }];
|
||||
service.addToQueue(filesFake);
|
||||
expect(true).toEqual(true);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
//# sourceMappingURL=upload.service.spec.js.map
|
@@ -0,0 +1 @@
|
||||
{"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;oBAEjC,OAAO,GAAG;wBACN,GAAG,EAAE,mBAAmB;wBACxB,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,CAAA;oBACD,OAAO,GAAG,IAAI,8BAAa,CAAC,OAAO,CAAC,CAAC;gBACzC,CAAC,CAAC,CAAC;gBAEH,YAAE,CAAC,iCAAiC,EAAE;oBAClC,IAAI,SAAS,GAAG,CAAC,EAAC,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC,EAAC,CAAC,CAAC;oBAC/C,OAAO,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;oBAC9B,MAAM,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;gBAC/B,CAAC,CAAC,CAAC;YAIP,CAAC,CAAC,CAAC"}
|
@@ -0,0 +1,65 @@
|
||||
/**
|
||||
* @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 return true if is a file', () => {
|
||||
let filesFake = [{name: 'fake-name', size: 0}];
|
||||
service.addToQueue(filesFake);
|
||||
expect(true).toEqual(true);
|
||||
});
|
||||
|
||||
|
||||
|
||||
});
|
@@ -32,8 +32,7 @@
|
||||
|
||||
// #3. Import the spec file explicitly
|
||||
Promise.all([
|
||||
System.import('src/authentication.service.spec'),
|
||||
System.import('src/upload.component.spec')
|
||||
System.import('src/services/upload.service.spec')
|
||||
])
|
||||
// #4. wait for all imports to load ...
|
||||
// then re-execute `window.onload` which
|
||||
|
Reference in New Issue
Block a user