add more to tests - need help though
This commit is contained in:
parent
6aacfbd25d
commit
6428455873
|
@ -163,4 +163,22 @@ describe('FieldFormatsRegistry', () => {
|
|||
expect(params).toHaveProperty('parsedUrl');
|
||||
});
|
||||
});
|
||||
|
||||
describe('setCustomParams', () => {
|
||||
test('should provide custom setting to formatters: timezone', () => {
|
||||
fieldFormatsRegistry = new FieldFormatsRegistry();
|
||||
fieldFormatsRegistry.init(
|
||||
getConfig,
|
||||
{
|
||||
parsedUrl: {
|
||||
origin: '',
|
||||
pathname: '',
|
||||
basePath: '',
|
||||
},
|
||||
},
|
||||
[]
|
||||
);
|
||||
fieldFormatsRegistry.setCustomParams({ timezone: 'America/New_York' });
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -17,9 +17,10 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import { FieldFormatsService } from './field_formats_service';
|
||||
import { DateFormat } from './converters/date_server';
|
||||
import { coreMock } from '../../../../core/server/mocks';
|
||||
import { FIELD_FORMAT_IDS } from '../../common';
|
||||
import { DateFormat } from './converters/date_server';
|
||||
import { FieldFormatsService } from './field_formats_service';
|
||||
|
||||
describe('FieldFormatService', () => {
|
||||
test('DateFormat is server version', async () => {
|
||||
|
@ -32,3 +33,22 @@ describe('FieldFormatService', () => {
|
|||
expect(DateFormatFromRegsitry).toEqual(DateFormat);
|
||||
});
|
||||
});
|
||||
|
||||
describe('DateFormat with custom timezone', () => {
|
||||
test('should provide custom setting to formatters: timezone', async () => {
|
||||
const service = new FieldFormatsService();
|
||||
const fieldFormatsService = await service.start();
|
||||
const uiSettings = coreMock.createStart().uiSettings.asScopedToClient({} as any);
|
||||
const fieldFormatsRegistry = await fieldFormatsService.fieldFormatServiceFactory(uiSettings);
|
||||
|
||||
fieldFormatsRegistry.setCustomParams({ timezone: 'America/Phoenix' }); // set the timezone into the registry
|
||||
|
||||
const fieldFormats = fieldFormatsRegistry.getByFieldType(FIELD_FORMAT_IDS.DATE as any);
|
||||
const DateFormatInstance = fieldFormats.find((F) => F.id === 'date');
|
||||
expect(DateFormatInstance).toBeDefined();
|
||||
if (DateFormatInstance) {
|
||||
const formatter = new DateFormatInstance();
|
||||
// how to call the formatter?
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue