add test for migrator
This commit is contained in:
@@ -105,6 +105,107 @@ describe('v1 migrator', () => {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('correctly parses state with queryRef', () => {
|
||||||
|
expect(
|
||||||
|
v1Migrator.parse({
|
||||||
|
panes: `{
|
||||||
|
"aaa": {
|
||||||
|
"datasource": "my-ds",
|
||||||
|
"queries": [
|
||||||
|
{
|
||||||
|
"refId": "A"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"range": {
|
||||||
|
"from": "now",
|
||||||
|
"to": "now-5m"
|
||||||
|
},
|
||||||
|
"queryRef": "library-query-123"
|
||||||
|
}
|
||||||
|
}`,
|
||||||
|
}).to
|
||||||
|
).toMatchObject({
|
||||||
|
panes: {
|
||||||
|
aaa: {
|
||||||
|
datasource: 'my-ds',
|
||||||
|
queries: [{ refId: 'A' }],
|
||||||
|
range: {
|
||||||
|
from: 'now',
|
||||||
|
to: 'now-5m',
|
||||||
|
},
|
||||||
|
queryRef: 'library-query-123',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('ignores queryRef if it is not a string', () => {
|
||||||
|
expect(
|
||||||
|
v1Migrator.parse({
|
||||||
|
panes: `{
|
||||||
|
"aaa": {
|
||||||
|
"datasource": "my-ds",
|
||||||
|
"queries": [
|
||||||
|
{
|
||||||
|
"refId": "A"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"range": {
|
||||||
|
"from": "now",
|
||||||
|
"to": "now-5m"
|
||||||
|
},
|
||||||
|
"queryRef": 123
|
||||||
|
}
|
||||||
|
}`,
|
||||||
|
}).to
|
||||||
|
).toMatchObject({
|
||||||
|
panes: {
|
||||||
|
aaa: {
|
||||||
|
datasource: 'my-ds',
|
||||||
|
queries: [{ refId: 'A' }],
|
||||||
|
range: {
|
||||||
|
from: 'now',
|
||||||
|
to: 'now-5m',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('handles empty string queryRef', () => {
|
||||||
|
expect(
|
||||||
|
v1Migrator.parse({
|
||||||
|
panes: `{
|
||||||
|
"aaa": {
|
||||||
|
"datasource": "my-ds",
|
||||||
|
"queries": [
|
||||||
|
{
|
||||||
|
"refId": "A"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"range": {
|
||||||
|
"from": "now",
|
||||||
|
"to": "now-5m"
|
||||||
|
},
|
||||||
|
"queryRef": ""
|
||||||
|
}
|
||||||
|
}`,
|
||||||
|
}).to
|
||||||
|
).toMatchObject({
|
||||||
|
panes: {
|
||||||
|
aaa: {
|
||||||
|
datasource: 'my-ds',
|
||||||
|
queries: [{ refId: 'A' }],
|
||||||
|
range: {
|
||||||
|
from: 'now',
|
||||||
|
to: 'now-5m',
|
||||||
|
},
|
||||||
|
queryRef: '',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('migrate', () => {
|
describe('migrate', () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user