@@ -28,6 +28,7 @@ import fx from 'common/core/animation/fx';
2828import { isRenderer } from 'core/utils/type' ;
2929
3030import config from 'core/config' ;
31+ import localization from 'localization' ;
3132import ArrayStore from 'common/data/array_store' ;
3233import {
3334 CHAT_EDITING_PREVIEW_CLASS ,
@@ -122,6 +123,7 @@ const moduleConfig = {
122123 this . getContextMenuItems = ( ) => $ ( this . getContextMenu ( ) . itemsContainer ( ) ) . find ( `.${ DX_MENU_ITEM_CLASS } ` ) ;
123124 this . getEditingPreview = ( ) => this . $element . find ( `.${ CHAT_EDITING_PREVIEW_CLASS } ` ) ;
124125 this . getCancelEditingButton = ( ) => this . $element . find ( `.${ CHAT_EDITING_PREVIEW_CANCEL_BUTTON_CLASS } ` ) ;
126+ this . getMessageListEmptyView = ( ) => this . $element . find ( `.${ CHAT_MESSAGELIST_EMPTY_VIEW_CLASS } ` ) ;
125127
126128 init ( ) ;
127129 } ,
@@ -758,6 +760,81 @@ QUnit.module('Chat', () => {
758760 } ) ;
759761 } ) ;
760762
763+ QUnit . module ( 'emptyViewTemplate' , ( ) => {
764+ QUnit . test ( 'emptyViewTemplate should set empty view content on init' , function ( assert ) {
765+ this . reinit ( {
766+ emptyViewTemplate : ( ) => $ ( '<h1>' ) . text ( 'This is empty' ) ,
767+ } ) ;
768+
769+ const $emptyView = this . getMessageListEmptyView ( ) ;
770+
771+ assert . strictEqual ( $emptyView . text ( ) , 'This is empty' ) ;
772+ } ) ;
773+
774+ QUnit . test ( 'emptyViewTemplate should set empty view content at runtime' , function ( assert ) {
775+ this . reinit ( { } ) ;
776+ this . instance . option ( 'emptyViewTemplate' , ( ) => $ ( '<h1>' ) . text ( 'This is empty' ) ) ;
777+
778+ const $emptyView = this . getMessageListEmptyView ( ) ;
779+
780+ assert . strictEqual ( $emptyView . text ( ) , 'This is empty' ) ;
781+ } ) ;
782+
783+ QUnit . test ( 'emptyViewTemplate specified as a string text should set empty view content' , function ( assert ) {
784+ this . reinit ( { emptyViewTemplate : 'empty' } ) ;
785+
786+ const $emptyView = this . getMessageListEmptyView ( ) ;
787+
788+ assert . strictEqual ( $emptyView . text ( ) , 'empty' ) ;
789+ } ) ;
790+
791+ QUnit . test ( 'emptyViewTemplate specified as a string with a html element should set empty view content' , function ( assert ) {
792+ this . reinit ( { emptyViewTemplate : '<p>p text</p>' } ) ;
793+
794+ const $emptyViewChild = this . getMessageListEmptyView ( ) . children ( ) ;
795+
796+ assert . strictEqual ( $emptyViewChild . text ( ) , 'p text' , 'template text is correct' ) ;
797+ assert . strictEqual ( $emptyViewChild . prop ( 'tagName' ) , 'P' , 'templte tag element is correct' ) ;
798+ } ) ;
799+
800+ QUnit . test ( 'emptyViewTemplate function argument should include Chat instance' , function ( assert ) {
801+ assert . expect ( 1 ) ;
802+
803+ const emptyViewTemplate = ( data ) => {
804+ assert . strictEqual ( data . component instanceof Chat , true , 'chat instance is passed' ) ;
805+ } ;
806+
807+ this . reinit ( { emptyViewTemplate } ) ;
808+ } ) ;
809+
810+ QUnit . test ( 'emptyViewTemplate function argument should include data with localized message and prompt' , function ( assert ) {
811+ assert . expect ( 2 ) ;
812+
813+ const defaultLocale = localization . locale ( ) ;
814+ const localizedEmptyListMessage = 'Lista wiadomości jest pusta' ;
815+ const localizedEmptyListPrompt = 'Napisz swoją pierwszą wiadomość' ;
816+
817+ const emptyViewTemplate = ( { data } ) => {
818+ assert . strictEqual ( data . message , localizedEmptyListMessage , 'localized message is passed' ) ;
819+ assert . strictEqual ( data . prompt , localizedEmptyListPrompt , 'localized prompt is passed' ) ;
820+ } ;
821+
822+ try {
823+ localization . loadMessages ( {
824+ 'pl' : {
825+ 'dxChat-emptyListMessage' : localizedEmptyListMessage ,
826+ 'dxChat-emptyListPrompt' : localizedEmptyListPrompt ,
827+ }
828+ } ) ;
829+ localization . locale ( 'pl' ) ;
830+
831+ this . reinit ( { emptyViewTemplate } ) ;
832+ } finally {
833+ localization . locale ( defaultLocale ) ;
834+ }
835+ } ) ;
836+ } ) ;
837+
761838 QUnit . test ( 'dayHeaderFormat option value should be passed to messageList on init' , function ( assert ) {
762839 const dayHeaderFormat = 'dd of MMMM, yyyy' ;
763840
0 commit comments