mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
* Enable OAUTH2 * Create SSO services * SSO improvements * Rollback sso login change * Add SSO configuration from Setting component * Refactoring * Remove login ECM/BPM toggle and move use the userpreference instead of store * fix host setting unit test * Fix unit test missing instance * use the Js api oauth * add logout component and clean sso not used class * fix dependencies cicle * add translation settings * fix style setting page * clean * JS APi should receive the oauth config from the userPreference and not from the config file * change login if SSO is present * missing spaces * add sso test in login component * add logout directive new properties test * Improve host setting and remove library reference * fix login test * Remove unused code * Fix authentication unit test * fix authguard unit test * fix csrf check login component * fix unit test core and demo shell * remove
95 lines
2.9 KiB
TypeScript
95 lines
2.9 KiB
TypeScript
/*!
|
|
* @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 { AlfrescoApiServiceMock, AppConfigService, StorageService, setupTestBed, CoreModule, UserPreferencesService } from '@alfresco/adf-core';
|
|
import { RatingService } from './rating.service';
|
|
import { TestBed } from '@angular/core/testing';
|
|
|
|
declare let jasmine: any;
|
|
|
|
describe('Rating service', () => {
|
|
|
|
let service;
|
|
let userPreferences: UserPreferencesService;
|
|
|
|
setupTestBed({
|
|
imports: [
|
|
CoreModule.forRoot()
|
|
]
|
|
});
|
|
|
|
beforeEach(() => {
|
|
userPreferences = TestBed.get(UserPreferencesService);
|
|
|
|
service = new RatingService(new AlfrescoApiServiceMock(new AppConfigService(null), userPreferences, new StorageService()));
|
|
});
|
|
|
|
beforeEach(() => {
|
|
jasmine.Ajax.install();
|
|
});
|
|
|
|
afterEach(() => {
|
|
jasmine.Ajax.uninstall();
|
|
});
|
|
|
|
it('Should get rating return an Observable', (done) => {
|
|
let ratingType: string = 'fiveStar';
|
|
let nodeId: string = 'fake-node-id';
|
|
|
|
service.getRating(nodeId, ratingType).subscribe((data) => {
|
|
expect(data.entry.myRating).toBe('1');
|
|
done();
|
|
});
|
|
|
|
jasmine.Ajax.requests.mostRecent().respondWith({
|
|
status: 200,
|
|
contentType: 'json',
|
|
responseText: {
|
|
'entry': {
|
|
myRating: 1,
|
|
'ratedAt': '2017-04-06T14:34:28.061+0000',
|
|
'id': 'fiveStar',
|
|
'aggregate': {'numberOfRatings': 1, 'average': 1.0}
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
it('Should post rating return an Observable', (done) => {
|
|
let ratingType: string = 'fiveStar';
|
|
let nodeId: string = 'fake-node-id';
|
|
|
|
service.postRating(nodeId, ratingType, 3).subscribe((data) => {
|
|
expect(data.entry.myRating).toBe('3');
|
|
done();
|
|
});
|
|
|
|
jasmine.Ajax.requests.mostRecent().respondWith({
|
|
status: 200,
|
|
contentType: 'json',
|
|
responseText: {
|
|
'entry': {
|
|
'myRating': 3,
|
|
'ratedAt': '2017-04-06T14:36:40.731+0000',
|
|
'id': 'fiveStar',
|
|
'aggregate': {'numberOfRatings': 1, 'average': 3.0}
|
|
}
|
|
}
|
|
});
|
|
});
|
|
});
|