mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-05-26 17:24:56 +00:00
Merge pull request #210 from Alfresco/dev-denys-core-tests
Unit tests for 'AlfrescoSettingsService'
This commit is contained in:
commit
86cef76ecd
@ -20,9 +20,13 @@ import { Injectable } from '@angular/core';
|
||||
@Injectable()
|
||||
export class AlfrescoSettingsService {
|
||||
|
||||
private _host: string = 'http://127.0.0.1:8080';
|
||||
private _contextPath = '/alfresco';
|
||||
private _apiBasePath: string = '/api/-default-/public/alfresco/versions/1';
|
||||
static DEFAULT_HOST_ADDRESS: string = 'http://127.0.0.1:8080';
|
||||
static DEFAULT_CONTEXT_PATH: string = '/alfresco';
|
||||
static DEFAULT_BASE_API_PATH: string = '/api/-default-/public/alfresco/versions/1';
|
||||
|
||||
private _host: string = AlfrescoSettingsService.DEFAULT_HOST_ADDRESS;
|
||||
private _contextPath = AlfrescoSettingsService.DEFAULT_CONTEXT_PATH;
|
||||
private _apiBasePath: string = AlfrescoSettingsService.DEFAULT_BASE_API_PATH;
|
||||
|
||||
public get host(): string {
|
||||
return this._host;
|
||||
@ -35,9 +39,4 @@ export class AlfrescoSettingsService {
|
||||
getApiBaseUrl(): string {
|
||||
return this._host + this._contextPath + this._apiBasePath;
|
||||
}
|
||||
|
||||
getAuthToken(): string {
|
||||
// todo: get proper token value
|
||||
return 'Basic ' + btoa('admin:admin');
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,47 @@
|
||||
/*!
|
||||
* @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 { describe, it, beforeEach } from '@angular/core/testing';
|
||||
import { AlfrescoSettingsService } from './AlfrescoSettingsService.service';
|
||||
|
||||
describe('AlfrescoSettingsService', () => {
|
||||
|
||||
let service: AlfrescoSettingsService;
|
||||
|
||||
beforeEach(() => {
|
||||
service = new AlfrescoSettingsService();
|
||||
});
|
||||
|
||||
it('should have default host', () => {
|
||||
expect(service.host).toBe(AlfrescoSettingsService.DEFAULT_HOST_ADDRESS);
|
||||
});
|
||||
|
||||
it('should change host', () => {
|
||||
// this test ensures 'host' getter/setter working properly
|
||||
let address = 'http://192.168.0.1';
|
||||
service.host = address;
|
||||
expect(service.host).toBe(address);
|
||||
});
|
||||
|
||||
it('should format api url', () => {
|
||||
let address = 'http://192.168.0.1';
|
||||
let expectedUrl =
|
||||
`${address}${AlfrescoSettingsService.DEFAULT_CONTEXT_PATH}${AlfrescoSettingsService.DEFAULT_BASE_API_PATH}`;
|
||||
service.host = address;
|
||||
expect(service.getApiBaseUrl()).toBe(expectedUrl);
|
||||
});
|
||||
});
|
Loading…
x
Reference in New Issue
Block a user