@@ -25,21 +25,13 @@ import {
2525 DataTableComponent ,
2626 ObjectDataTableAdapter ,
2727 ShowHeaderMode ,
28- ThumbnailService
28+ ThumbnailService ,
29+ UnitTestingUtils
2930} from '@alfresco/adf-core' ;
3031import { FavoritePaging , FavoritePagingList , Node , NodeEntry , NodePaging } from '@alfresco/js-api' ;
3132import { HarnessLoader } from '@angular/cdk/testing' ;
3233import { TestbedHarnessEnvironment } from '@angular/cdk/testing/testbed' ;
33- import {
34- Component ,
35- CUSTOM_ELEMENTS_SCHEMA ,
36- Injector ,
37- QueryList ,
38- runInInjectionContext ,
39- SimpleChange ,
40- SimpleChanges ,
41- ViewChild
42- } from '@angular/core' ;
34+ import { Component , CUSTOM_ELEMENTS_SCHEMA , Injector , QueryList , runInInjectionContext , SimpleChange , SimpleChanges , ViewChild } from '@angular/core' ;
4335import { ComponentFixture , fakeAsync , TestBed , tick } from '@angular/core/testing' ;
4436import { MatProgressSpinnerHarness } from '@angular/material/progress-spinner/testing' ;
4537import { By } from '@angular/platform-browser' ;
@@ -94,6 +86,12 @@ describe('DocumentList', () => {
9486 let spyFolderNode : any ;
9587 let authenticationService : AuthenticationService ;
9688 let injector : Injector ;
89+ let unitTestingUtils : UnitTestingUtils ;
90+
91+ const getEmptyFolderDragDropTitle = ( ) : string => unitTestingUtils . getByCSS ( '.adf-empty-folder-drag-drop' ) ?. nativeElement ?. textContent ;
92+
93+ const getEmptyFolderDragDropSubtitle = ( ) : string =>
94+ unitTestingUtils . getByCSS ( '.adf-empty-folder-any-files-here-to-add' ) ?. nativeElement ?. textContent ;
9795
9896 beforeEach ( ( ) => {
9997 TestBed . configureTestingModule ( {
@@ -109,6 +107,7 @@ describe('DocumentList', () => {
109107
110108 element = fixture . nativeElement ;
111109 documentList = fixture . componentInstance ;
110+ unitTestingUtils = new UnitTestingUtils ( fixture . debugElement ) ;
112111
113112 documentListService = TestBed . inject ( DocumentListService ) ;
114113 customResourcesService = TestBed . inject ( CustomResourcesService ) ;
@@ -1139,7 +1138,7 @@ describe('DocumentList', () => {
11391138 fixture . detectChanges ( ) ;
11401139 runInInjectionContext ( injector , ( ) => {
11411140 documentList . dataTable = new DataTableComponent ( null , null , matIconRegistryMock , domSanitizerMock ) ;
1142- } )
1141+ } ) ;
11431142 expect ( documentList . dataTable ) . toBeDefined ( ) ;
11441143 expect ( fixture . debugElement . query ( By . css ( 'adf-empty-list' ) ) ) . not . toBeNull ( ) ;
11451144 } ) ;
@@ -1160,7 +1159,7 @@ describe('DocumentList', () => {
11601159 it ( 'should empty folder NOT show the pagination' , ( ) => {
11611160 runInInjectionContext ( injector , ( ) => {
11621161 documentList . dataTable = new DataTableComponent ( null , null , matIconRegistryMock , domSanitizerMock ) ;
1163- } )
1162+ } ) ;
11641163
11651164 expect ( documentList . isEmpty ( ) ) . toBeTruthy ( ) ;
11661165 expect ( element . querySelector ( 'alfresco-pagination' ) ) . toBe ( null ) ;
@@ -1651,6 +1650,44 @@ describe('DocumentList', () => {
16511650 expect ( dialog . open ) . toHaveBeenCalledWith ( FileAutoDownloadComponent , { disableClose : true , data : node } ) ;
16521651 } ) ;
16531652
1653+ it ( 'should display drag and drop title by default' , ( ) => {
1654+ fixture . detectChanges ( ) ;
1655+ expect ( getEmptyFolderDragDropTitle ( ) ) . toBe ( 'ADF-DATATABLE.EMPTY.DRAG-AND-DROP.TITLE' ) ;
1656+ } ) ;
1657+
1658+ it ( 'should display drag and drop title if displayDragAndDropHint is set to true' , ( ) => {
1659+ documentList . displayDragAndDropHint = true ;
1660+
1661+ fixture . detectChanges ( ) ;
1662+ expect ( getEmptyFolderDragDropTitle ( ) ) . toBe ( 'ADF-DATATABLE.EMPTY.DRAG-AND-DROP.TITLE' ) ;
1663+ } ) ;
1664+
1665+ it ( 'should not display drag and drop title if displayDragAndDropHint is set to false' , ( ) => {
1666+ documentList . displayDragAndDropHint = false ;
1667+
1668+ fixture . detectChanges ( ) ;
1669+ expect ( getEmptyFolderDragDropTitle ( ) ) . toBeUndefined ( ) ;
1670+ } ) ;
1671+
1672+ it ( 'should display drag and drop subtitle by default' , ( ) => {
1673+ fixture . detectChanges ( ) ;
1674+ expect ( getEmptyFolderDragDropSubtitle ( ) ) . toBe ( 'ADF-DATATABLE.EMPTY.DRAG-AND-DROP.SUBTITLE' ) ;
1675+ } ) ;
1676+
1677+ it ( 'should display drag and drop subtitle if displayDragAndDropHint is set to true' , ( ) => {
1678+ documentList . displayDragAndDropHint = true ;
1679+
1680+ fixture . detectChanges ( ) ;
1681+ expect ( getEmptyFolderDragDropSubtitle ( ) ) . toBe ( 'ADF-DATATABLE.EMPTY.DRAG-AND-DROP.SUBTITLE' ) ;
1682+ } ) ;
1683+
1684+ it ( 'should not display drag and drop subtitle if displayDragAndDropHint is set to false' , ( ) => {
1685+ documentList . displayDragAndDropHint = false ;
1686+
1687+ fixture . detectChanges ( ) ;
1688+ expect ( getEmptyFolderDragDropSubtitle ( ) ) . toBeUndefined ( ) ;
1689+ } ) ;
1690+
16541691 describe ( 'Preselect nodes' , ( ) => {
16551692 beforeEach ( ( ) => {
16561693 spyOn ( thumbnailService , 'getMimeTypeIcon' ) . and . returnValue ( `assets/images/ft_ic_created.svg` ) ;
0 commit comments