-
diff --git a/ng2-components/ng2-alfresco-search/src/components/alfresco-search-control.component.ts b/ng2-components/ng2-alfresco-search/src/components/alfresco-search-control.component.ts
index 81bd5ca99d..a2ccb32cca 100644
--- a/ng2-components/ng2-alfresco-search/src/components/alfresco-search-control.component.ts
+++ b/ng2-components/ng2-alfresco-search/src/components/alfresco-search-control.component.ts
@@ -16,25 +16,22 @@
*/
import { Control, Validators } from '@angular/common';
-import { Component, Input, Output, ElementRef, EventEmitter, AfterViewInit, ViewChild } from '@angular/core';
+import { Component, Input, Output, ElementRef, EventEmitter, ViewChild } from '@angular/core';
import { AlfrescoPipeTranslate, AlfrescoTranslationService } from 'ng2-alfresco-core';
import { AlfrescoSearchAutocompleteComponent } from './alfresco-search-autocomplete.component';
import { SearchTermValidator } from './../forms/search-term-validator';
declare let __moduleName: string;
-declare var componentHandler: any;
@Component({
moduleId: __moduleName,
selector: 'alfresco-search-control',
- styles: [
- ],
templateUrl: './alfresco-search-control.component.html',
styleUrls: ['./alfresco-search-control.component.css'],
directives: [AlfrescoSearchAutocompleteComponent],
pipes: [AlfrescoPipeTranslate]
})
-export class AlfrescoSearchControlComponent implements AfterViewInit {
+export class AlfrescoSearchControlComponent {
@Input()
searchTerm = '';
@@ -77,21 +74,15 @@ export class AlfrescoSearchControlComponent implements AfterViewInit {
this.searchControl.valueChanges.map(value => this.searchControl.valid ? value : '')
.debounceTime(400).distinctUntilChanged().subscribe(
- (value: string) => {
- this.autocompleteSearchTerm = value;
- this.searchValid = this.searchControl.valid;
- }
- );
+ (value: string) => {
+ this.autocompleteSearchTerm = value;
+ this.searchValid = this.searchControl.valid;
+ }
+ );
translate.addTranslationFolder('node_modules/ng2-alfresco-search/dist/src');
}
- ngAfterViewInit(): void {
- if (componentHandler) {
- componentHandler.upgradeAllRegistered();
- }
- }
-
getTextFieldClassName(): string {
return 'mdl-textfield mdl-js-textfield' + (this.expandable ? ' mdl-textfield--expandable' : '');
}
diff --git a/ng2-components/ng2-alfresco-search/src/components/alfresco-search.component.ts b/ng2-components/ng2-alfresco-search/src/components/alfresco-search.component.ts
index 0b9112cf39..3fc41ab0b7 100644
--- a/ng2-components/ng2-alfresco-search/src/components/alfresco-search.component.ts
+++ b/ng2-components/ng2-alfresco-search/src/components/alfresco-search.component.ts
@@ -64,7 +64,7 @@ export class AlfrescoSearchComponent implements OnChanges, OnInit {
route: any[] = [];
- constructor(private _alfrescoSearchService: AlfrescoSearchService,
+ constructor(private alfrescoSearchService: AlfrescoSearchService,
private translate: AlfrescoTranslationService,
private _alfrescoThumbnailService: AlfrescoThumbnailService,
@Optional() params: RouteParams) {
@@ -118,7 +118,7 @@ export class AlfrescoSearchComponent implements OnChanges, OnInit {
*/
public displaySearchResults(searchTerm): void {
if (searchTerm !== null) {
- this._alfrescoSearchService
+ this.alfrescoSearchService
.getLiveSearchResults(searchTerm)
.subscribe(
results => {
diff --git a/ng2-components/ng2-alfresco-search/src/services/alfresco-search.service.spec.ts b/ng2-components/ng2-alfresco-search/src/services/alfresco-search.service.spec.ts
index 3877bf2b86..e72f0c8509 100644
--- a/ng2-components/ng2-alfresco-search/src/services/alfresco-search.service.spec.ts
+++ b/ng2-components/ng2-alfresco-search/src/services/alfresco-search.service.spec.ts
@@ -15,17 +15,76 @@
* limitations under the License.
*/
-import {
- describe,
- beforeEach
-} from '@angular/core/testing';
-import {AlfrescoSearchService} from './alfresco-search.service';
+import { it, describe, beforeEach, inject, beforeEachProviders } from '@angular/core/testing';
+import { AlfrescoSearchService } from './alfresco-search.service';
+import { AlfrescoAuthenticationService, AlfrescoSettingsService } from 'ng2-alfresco-core';
+
+declare let jasmine: any;
describe('AlfrescoSearchService', () => {
- let service: AlfrescoSearchService;
+ let service: any;
- beforeEach(() => {
- service = new AlfrescoSearchService(null);
+ let fakeSearch = {
+ list: {
+ pagination: {
+ count: 1,
+ hasMoreItems: false,
+ totalItems: 1,
+ skipCount: 0,
+ maxItems: 100
+ },
+ entries: [
+ {
+ entry: {
+ id: '123',
+ name: 'MyDoc',
+ content: {
+ mimetype: 'text/plain'
+ },
+ createdByUser: {
+ displayName: 'John Doe'
+ },
+ modifiedByUser: {
+ displayName: 'John Doe'
+ }
+ }
+ }
+ ]
+ }
+ };
+
+ beforeEachProviders(() => {
+ return [
+ AlfrescoSearchService,
+ AlfrescoSettingsService,
+ AlfrescoAuthenticationService
+ ];
});
+
+ beforeEach(inject([AlfrescoSearchService], (alfrescoSearchService: AlfrescoSearchService) => {
+ jasmine.Ajax.install();
+ service = alfrescoSearchService;
+ }));
+
+ afterEach(() => {
+ jasmine.Ajax.uninstall();
+ });
+
+ it('should return search list', (done) => {
+ service.getSearchNodesPromise('MyDoc').then(
+ (res) => {
+ expect(res).toBeDefined();
+ expect(res.list.entries[0].entry.name).toEqual('MyDoc');
+ done();
+ }
+ );
+
+ jasmine.Ajax.requests.mostRecent().respondWith({
+ 'status': 200,
+ contentType: 'application/json',
+ responseText: JSON.stringify(fakeSearch)
+ });
+ });
+
});
diff --git a/ng2-components/ng2-alfresco-search/src/services/alfresco-search.service.ts b/ng2-components/ng2-alfresco-search/src/services/alfresco-search.service.ts
index f248e4d553..cbfc12dbf3 100644
--- a/ng2-components/ng2-alfresco-search/src/services/alfresco-search.service.ts
+++ b/ng2-components/ng2-alfresco-search/src/services/alfresco-search.service.ts
@@ -17,12 +17,7 @@
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs/Rx';
-
-import {
- AlfrescoAuthenticationService
-} from 'ng2-alfresco-core';
-
-declare let AlfrescoApi: any;
+import { AlfrescoAuthenticationService } from 'ng2-alfresco-core';
/**
* Internal service used by Document List component.
@@ -33,14 +28,14 @@ export class AlfrescoSearchService {
constructor(private authService: AlfrescoAuthenticationService) {
}
- private getSearchNodesPromise(term: string) {
+ public getSearchNodesPromise(term: string) {
let nodeId = '-root-';
let opts = {
include: ['path'],
rootNodeId: nodeId,
nodeType: 'cm:content'
};
- return this.authService.getAlfrescoApi().search.liveSearchNodes(term, opts);
+ return this.authService.getAlfrescoApi().core.searchApi.liveSearchNodes(term, opts);
}
/**
diff --git a/ng2-components/ng2-alfresco-search/src/services/alfresco-thumbnail.service.spec.ts b/ng2-components/ng2-alfresco-search/src/services/alfresco-thumbnail.service.spec.ts
index b5ddf4442c..32711fd171 100644
--- a/ng2-components/ng2-alfresco-search/src/services/alfresco-thumbnail.service.spec.ts
+++ b/ng2-components/ng2-alfresco-search/src/services/alfresco-thumbnail.service.spec.ts
@@ -15,11 +15,8 @@
* limitations under the License.
*/
-import {
- describe,
- beforeEach
-} from '@angular/core/testing';
-import {AlfrescoThumbnailService} from './alfresco-thumbnail.service';
+import { describe, beforeEach } from '@angular/core/testing';
+import { AlfrescoThumbnailService } from './alfresco-thumbnail.service';
describe('AlfrescoThumbnailService', () => {
diff --git a/ng2-components/ng2-alfresco-search/src/services/alfresco-thumbnail.service.ts b/ng2-components/ng2-alfresco-search/src/services/alfresco-thumbnail.service.ts
index d05c0d1c3a..593f2c8921 100644
--- a/ng2-components/ng2-alfresco-search/src/services/alfresco-thumbnail.service.ts
+++ b/ng2-components/ng2-alfresco-search/src/services/alfresco-thumbnail.service.ts
@@ -16,9 +16,7 @@
*/
import { Injectable } from '@angular/core';
-import {
- AlfrescoContentService
-} from 'ng2-alfresco-core';
+import { AlfrescoContentService } from 'ng2-alfresco-core';
@Injectable()
export class AlfrescoThumbnailService {