@@ -34,34 +34,6 @@ class MockFieldFormatter {}
3434
3535fieldFormatsMock . getInstance = jest . fn ( ) . mockImplementation ( ( ) => new MockFieldFormatter ( ) ) as any ;
3636
37- jest . mock ( '../../field_mapping' , ( ) => {
38- const originalModule = jest . requireActual ( '../../field_mapping' ) ;
39-
40- return {
41- ...originalModule ,
42- expandShorthand : jest . fn ( ( ) => ( {
43- id : true ,
44- title : true ,
45- fieldFormatMap : {
46- _serialize : jest . fn ( ) . mockImplementation ( ( ) => { } ) ,
47- _deserialize : jest . fn ( ) . mockImplementation ( ( ) => [ ] ) ,
48- } ,
49- fields : {
50- _serialize : jest . fn ( ) . mockImplementation ( ( ) => { } ) ,
51- _deserialize : jest . fn ( ) . mockImplementation ( ( fields ) => fields ) ,
52- } ,
53- sourceFilters : {
54- _serialize : jest . fn ( ) . mockImplementation ( ( ) => { } ) ,
55- _deserialize : jest . fn ( ) . mockImplementation ( ( ) => undefined ) ,
56- } ,
57- typeMeta : {
58- _serialize : jest . fn ( ) . mockImplementation ( ( ) => { } ) ,
59- _deserialize : jest . fn ( ) . mockImplementation ( ( ) => undefined ) ,
60- } ,
61- } ) ) ,
62- } ;
63- } ) ;
64-
6537// helper function to create index patterns
6638function create ( id : string ) {
6739 const {
@@ -211,6 +183,20 @@ describe('IndexPattern', () => {
211183 } ) ;
212184 } ) ;
213185
186+ describe ( 'setFieldFormat and deleteFieldFormaat' , ( ) => {
187+ test ( 'should persist changes' , ( ) => {
188+ const formatter = {
189+ toJSON : ( ) => ( { id : 'bytes' } ) ,
190+ } as FieldFormat ;
191+ indexPattern . getFormatterForField = ( ) => formatter ;
192+ indexPattern . setFieldFormat ( 'bytes' , { id : 'bytes' } ) ;
193+ expect ( indexPattern . toSpec ( ) . fieldFormats ) . toEqual ( { bytes : { id : 'bytes' } } ) ;
194+
195+ indexPattern . deleteFieldFormat ( 'bytes' ) ;
196+ expect ( indexPattern . toSpec ( ) . fieldFormats ) . toEqual ( { } ) ;
197+ } ) ;
198+ } ) ;
199+
214200 describe ( 'toSpec' , ( ) => {
215201 test ( 'should match snapshot' , ( ) => {
216202 const formatter = {
0 commit comments