11import { Config } from '../../src/config' ;
22import Storage from '../../src/storage/storage' ;
33import { Translator } from '../../src/i18n/language' ;
4+ import { PluginPosition } from '../../src/plugin' ;
45
56describe ( 'Config' , ( ) => {
6- //let config: Partial<Config> = null;
7-
8- //beforeEach(() => {
9- // config = Config.fromPartialConfig({
10- // data: [[1, 2, 3]],
11- // });
12- //});
13-
147 it ( 'should have data property' , ( ) => {
158 const config = Config . fromPartialConfig ( {
169 data : [ [ 1 , 2 , 3 ] ] ,
@@ -20,16 +13,16 @@ describe('Config', () => {
2013
2114 it ( 'assign should set the default when partial config is empty' , ( ) => {
2215 const config = new Config ( ) ;
23- config . assign ( { } )
24- expect ( config . width ) . toEqual ( " 100%" ) ;
16+ config . assign ( { } ) ;
17+ expect ( config . width ) . toEqual ( ' 100%' ) ;
2518 } ) ;
2619
2720 it ( 'assign should set the correct default' , ( ) => {
2821 const config = new Config ( ) ;
2922 config . assign ( {
30- width : " 500px"
31- } )
32- expect ( config . width ) . toEqual ( " 500px" ) ;
23+ width : ' 500px' ,
24+ } ) ;
25+ expect ( config . width ) . toEqual ( ' 500px' ) ;
3326 } ) ;
3427
3528 it ( 'should return the correct values' , ( ) => {
@@ -61,7 +54,11 @@ describe('Config', () => {
6154 search : true ,
6255 } ) ;
6356
64- expect ( conf . plugin . get ( 'search' ) ) . toHaveLength ( 1 ) ;
57+ expect ( conf . plugin . get ( 'search' ) ) . toStrictEqual ( {
58+ id : 'search' ,
59+ position : PluginPosition . Header ,
60+ component : expect . any ( Function ) ,
61+ } ) ;
6562 } ) ;
6663
6764 it ( 'should create a userConfig with pagination' , ( ) => {
@@ -71,7 +68,11 @@ describe('Config', () => {
7168 pagination : true ,
7269 } ) ;
7370
74- expect ( conf . plugin . get ( 'pagination' ) ) . toHaveLength ( 1 ) ;
71+ expect ( conf . plugin . get ( 'pagination' ) ) . toStrictEqual ( {
72+ id : 'pagination' ,
73+ position : PluginPosition . Footer ,
74+ component : expect . any ( Function ) ,
75+ } ) ;
7576 } ) ;
7677
7778 it ( 'should create a userConfig with header' , ( ) => {
@@ -100,11 +101,7 @@ describe('Config', () => {
100101 } ) ;
101102
102103 expect ( conf . header . columns . map ( ( x ) => x . name ) ) . toStrictEqual ( cols ) ;
103- expect ( conf . header . columns . map ( ( x ) => x . sort ) ) . toStrictEqual ( [
104- { } ,
105- { } ,
106- { } ,
107- ] ) ;
104+ expect ( conf . header . columns . map ( ( x ) => x . sort ) ) . toStrictEqual ( [ { } , { } , { } ] ) ;
108105 } ) ;
109106
110107 it ( 'should create a userConfig with header and custom sort' , ( ) => {
@@ -144,11 +141,12 @@ describe('Config', () => {
144141
145142 it ( 'should update config' , ( ) => {
146143 const config = Config . fromPartialConfig ( {
147- data : [ ]
144+ data : [ ] ,
148145 } ) . update ( {
149146 autoWidth : false ,
150147 } ) ;
151148 expect ( config . width ) . toBe ( '100%' ) ;
149+ expect ( config . height ) . toBe ( 'auto' ) ;
152150 expect ( config . autoWidth ) . toBeFalsy ( ) ;
153151 } ) ;
154152} ) ;
0 commit comments