mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
fix upload mock
This commit is contained in:
@@ -1,41 +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 {Observable} from 'rxjs/Rx';
|
||||
|
||||
import {
|
||||
AlfrescoAuthenticationService
|
||||
} from 'ng2-alfresco-core';
|
||||
import {AlfrescoSearchService} from './../../src/services/alfresco-search.service';
|
||||
|
||||
export class AlfrescoServiceMock extends AlfrescoSearchService {
|
||||
|
||||
_folderToReturn: any = {};
|
||||
|
||||
constructor(
|
||||
authService: AlfrescoAuthenticationService = null
|
||||
) {
|
||||
super(authService);
|
||||
}
|
||||
|
||||
getFolder(folder: string) {
|
||||
return Observable.create(observer => {
|
||||
observer.next(this._folderToReturn);
|
||||
observer.complete();
|
||||
});
|
||||
}
|
||||
}
|
@@ -1,36 +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 { Injectable } from '@angular/core';
|
||||
|
||||
@Injectable()
|
||||
export class AlfrescoSettingsServiceMock {
|
||||
|
||||
static DEFAULT_HOST_ADDRESS: string = 'fakehost';
|
||||
|
||||
private providers: string[] = ['ECM', 'BPM'];
|
||||
|
||||
private _host: string = AlfrescoSettingsServiceMock.DEFAULT_HOST_ADDRESS;
|
||||
|
||||
public get ecmHost(): string {
|
||||
return this._host;
|
||||
}
|
||||
|
||||
getProviders(): string [] {
|
||||
return this.providers;
|
||||
}
|
||||
}
|
@@ -21,8 +21,8 @@ import { UploadButtonComponent } from './upload-button.component';
|
||||
import { AlfrescoTranslationService, AlfrescoSettingsService, AlfrescoAuthenticationService } from 'ng2-alfresco-core';
|
||||
import { TranslationMock } from '../assets/translation.service.mock';
|
||||
import { UploadService } from '../services/upload.service';
|
||||
import { AlfrescoSettingsServiceMock } from '../assets/AlfrescoSettingsService.service.mock';
|
||||
import { HTTP_PROVIDERS } from '@angular/http';
|
||||
|
||||
declare var AlfrescoApi: any;
|
||||
|
||||
describe('AlfrescoUploadButton', () => {
|
||||
@@ -69,7 +69,7 @@ describe('AlfrescoUploadButton', () => {
|
||||
beforeEachProviders(() => {
|
||||
return [
|
||||
HTTP_PROVIDERS,
|
||||
{ provide: AlfrescoSettingsService, useClass: AlfrescoSettingsServiceMock },
|
||||
AlfrescoSettingsService,
|
||||
AlfrescoAuthenticationService,
|
||||
{ provide: AlfrescoTranslationService, useClass: TranslationMock },
|
||||
UploadService
|
||||
|
@@ -19,7 +19,6 @@ import { describe, expect, it, inject, beforeEach, beforeEachProviders } from '@
|
||||
import { TestComponentBuilder } from '@angular/compiler/testing';
|
||||
import { UploadDragAreaComponent } from './upload-drag-area.component';
|
||||
import { AlfrescoTranslationService, AlfrescoSettingsService, AlfrescoAuthenticationService } from 'ng2-alfresco-core';
|
||||
import { AlfrescoSettingsServiceMock } from '../assets/AlfrescoSettingsService.service.mock';
|
||||
import { TranslationMock } from '../assets/translation.service.mock';
|
||||
import { UploadService } from '../services/upload.service';
|
||||
import { HTTP_PROVIDERS } from '@angular/http';
|
||||
@@ -38,7 +37,7 @@ describe('AlfrescoUploadDragArea', () => {
|
||||
beforeEachProviders(() => {
|
||||
return [
|
||||
HTTP_PROVIDERS,
|
||||
{ provide: AlfrescoSettingsService, useClass: AlfrescoSettingsServiceMock },
|
||||
AlfrescoSettingsService,
|
||||
AlfrescoAuthenticationService,
|
||||
{ provide: AlfrescoTranslationService, useClass: TranslationMock },
|
||||
UploadService
|
||||
|
@@ -19,7 +19,6 @@ import { it, describe, inject, beforeEach, beforeEachProviders } from '@angular/
|
||||
import { EventEmitter } from '@angular/core';
|
||||
import { UploadService } from './upload.service';
|
||||
import { AlfrescoSettingsService, AlfrescoAuthenticationService } from 'ng2-alfresco-core';
|
||||
import { AlfrescoSettingsServiceMock } from '../assets/AlfrescoSettingsService.service.mock';
|
||||
|
||||
declare let AlfrescoApi: any;
|
||||
declare let jasmine: any;
|
||||
@@ -39,7 +38,7 @@ describe('AlfrescoUploadService', () => {
|
||||
|
||||
beforeEachProviders(() => {
|
||||
return [
|
||||
{ provide: AlfrescoSettingsService, useClass: AlfrescoSettingsServiceMock },
|
||||
AlfrescoSettingsService,
|
||||
AlfrescoAuthenticationService,
|
||||
UploadService
|
||||
];
|
||||
@@ -86,7 +85,7 @@ describe('AlfrescoUploadService', () => {
|
||||
service.uploadFilesInTheQueue('fake-dir', emitter);
|
||||
|
||||
let request = jasmine.Ajax.requests.mostRecent();
|
||||
expect(request.url).toBe('fakehost/alfresco/api/-default-/public/alfresco/versions/1/nodes/-root-/children');
|
||||
expect(request.url).toBe('http://localhost:8080/alfresco/api/-default-/public/alfresco/versions/1/nodes/-root-/children');
|
||||
expect(request.method).toBe('POST');
|
||||
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
@@ -108,7 +107,7 @@ describe('AlfrescoUploadService', () => {
|
||||
service.addToQueue(filesFake);
|
||||
service.uploadFilesInTheQueue('', emitter);
|
||||
expect(jasmine.Ajax.requests.mostRecent().url)
|
||||
.toBe('fakehost/alfresco/api/-default-/public/alfresco/versions/1/nodes/-root-/children');
|
||||
.toBe('http://localhost:8080/alfresco/api/-default-/public/alfresco/versions/1/nodes/-root-/children');
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
'status': 404,
|
||||
contentType: 'text/plain',
|
||||
|
Reference in New Issue
Block a user