Chore: Removes console outputs in FieldCache.test.ts (#45141)

This commit is contained in:
Hugo Häggmark
2022-02-09 14:30:19 +01:00
committed by GitHub
parent f67e02cb2f
commit f9bb0832ce
@@ -69,24 +69,33 @@ describe('FieldCache', () => {
}); });
describe('field retrieval', () => { describe('field retrieval', () => {
const frame = toDataFrame({ let fieldCache: FieldCache;
fields: [
{ name: 'time', type: FieldType.time, values: [100, 200, 300] }, beforeEach(() => {
{ name: 'name', type: FieldType.string, values: ['a', 'b', 'c'] }, const frame = toDataFrame({
{ name: 'value', type: FieldType.number, values: [1, 2, 3] }, fields: [
{ name: 'value', type: FieldType.number, values: [4, 5, 6] }, { name: 'time', type: FieldType.time, values: [100, 200, 300] },
], { name: 'name', type: FieldType.string, values: ['a', 'b', 'c'] },
{ name: 'value', type: FieldType.number, values: [1, 2, 3] },
{ name: 'value', type: FieldType.number, values: [4, 5, 6] },
],
});
// Because we're using duplicate field names in the test case, we need to disable the warning,
// so it doesn't show up in the test output
const consoleWarnSpy = jest.spyOn(console, 'warn').mockImplementation(() => {});
fieldCache = new FieldCache(frame);
consoleWarnSpy.mockRestore();
}); });
const ext = new FieldCache(frame);
it('should get the first field with a duplicate name', () => { it('should get the first field with a duplicate name', () => {
const field = ext.getFieldByName('value'); const field = fieldCache.getFieldByName('value');
expect(field!.name).toEqual('value'); expect(field!.name).toEqual('value');
expect(field!.values.toArray()).toEqual([1, 2, 3]); expect(field!.values.toArray()).toEqual([1, 2, 3]);
}); });
it('should return index of the field', () => { it('should return index of the field', () => {
const field = ext.getFirstFieldOfType(FieldType.number); const field = fieldCache.getFirstFieldOfType(FieldType.number);
expect(field!.index).toEqual(2); expect(field!.index).toEqual(2);
}); });
}); });