#46 upload component Unit test

This commit is contained in:
mauriziovitale84
2016-05-05 21:41:56 +01:00
parent 817fb5c961
commit a92f706c7d
5 changed files with 139 additions and 2 deletions

View File

@@ -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);
});
});