|
|
|
@ -80,6 +80,59 @@ describe('Rename By Regex Transformer', () => { |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
it('should be able to replace globally', async () => { |
|
|
|
|
const cfg: DataTransformerConfig<RenameByRegexTransformerOptions> = { |
|
|
|
|
id: DataTransformerID.renameByRegex, |
|
|
|
|
options: { |
|
|
|
|
regex: '/e/g', |
|
|
|
|
renamePattern: 'E', |
|
|
|
|
}, |
|
|
|
|
}; |
|
|
|
|
await expect(transformDataFrame([cfg], [data])).toEmitValuesWith((received) => { |
|
|
|
|
const data = received[0]; |
|
|
|
|
const frame = data[0]; |
|
|
|
|
expect(frame.fields).toMatchInlineSnapshot(` |
|
|
|
|
Array [ |
|
|
|
|
Object { |
|
|
|
|
"config": Object { |
|
|
|
|
"displayName": "TimE", |
|
|
|
|
"name": "Time", |
|
|
|
|
}, |
|
|
|
|
"name": "Time", |
|
|
|
|
"state": Object { |
|
|
|
|
"displayName": "TimE", |
|
|
|
|
"multipleFrames": false, |
|
|
|
|
}, |
|
|
|
|
"type": "time", |
|
|
|
|
"values": Array [ |
|
|
|
|
3000, |
|
|
|
|
4000, |
|
|
|
|
5000, |
|
|
|
|
6000, |
|
|
|
|
], |
|
|
|
|
}, |
|
|
|
|
Object { |
|
|
|
|
"config": Object { |
|
|
|
|
"displayName": "wEb-01.ExamplE.com", |
|
|
|
|
}, |
|
|
|
|
"name": "Value", |
|
|
|
|
"state": Object { |
|
|
|
|
"displayName": "wEb-01.ExamplE.com", |
|
|
|
|
"multipleFrames": false, |
|
|
|
|
}, |
|
|
|
|
"type": "number", |
|
|
|
|
"values": Array [ |
|
|
|
|
10000.3, |
|
|
|
|
10000.4, |
|
|
|
|
10000.5, |
|
|
|
|
10000.6, |
|
|
|
|
], |
|
|
|
|
}, |
|
|
|
|
] |
|
|
|
|
`);
|
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
it('should not rename misses', async () => { |
|
|
|
|
const cfg: DataTransformerConfig<RenameByRegexTransformerOptions> = { |
|
|
|
|
id: DataTransformerID.renameByRegex, |
|
|
|
@ -147,7 +200,6 @@ describe('Rename By Regex Transformer', () => { |
|
|
|
|
Array [ |
|
|
|
|
Object { |
|
|
|
|
"config": Object { |
|
|
|
|
"displayName": "Time", |
|
|
|
|
"name": "Time", |
|
|
|
|
}, |
|
|
|
|
"name": "Time", |
|
|
|
|