Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
12c43d64
Commit
12c43d64
authored
Sep 28, 2018
by
David Kaltschmidt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added test for url state in Explore
parent
c3e0d420
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
96 additions
and
0 deletions
+96
-0
public/app/features/explore/Wrapper.test.tsx
+96
-0
No files found.
public/app/features/explore/Wrapper.test.tsx
0 → 100644
View file @
12c43d64
import
{
serializeStateToUrlParam
,
parseUrlState
}
from
'./Wrapper'
;
import
{
DEFAULT_RANGE
}
from
'./TimePicker'
;
import
{
ExploreState
}
from
'./Explore'
;
const
DEFAULT_EXPLORE_STATE
:
ExploreState
=
{
datasource
:
null
,
datasourceError
:
null
,
datasourceLoading
:
null
,
datasourceMissing
:
false
,
datasourceName
:
''
,
graphResult
:
null
,
history
:
[],
latency
:
0
,
loading
:
false
,
logsResult
:
null
,
queries
:
[],
queryErrors
:
[],
queryHints
:
[],
range
:
DEFAULT_RANGE
,
requestOptions
:
null
,
showingGraph
:
true
,
showingLogs
:
true
,
showingTable
:
true
,
supportsGraph
:
null
,
supportsLogs
:
null
,
supportsTable
:
null
,
tableResult
:
null
,
};
describe
(
'Wrapper state functions'
,
()
=>
{
describe
(
'parseUrlState'
,
()
=>
{
it
(
'returns default state on empty string'
,
()
=>
{
expect
(
parseUrlState
(
''
)).
toMatchObject
({
datasource
:
null
,
queries
:
[],
range
:
DEFAULT_RANGE
,
});
});
});
describe
(
'serializeStateToUrlParam'
,
()
=>
{
it
(
'returns url parameter value for a state object'
,
()
=>
{
const
state
=
{
...
DEFAULT_EXPLORE_STATE
,
datasourceName
:
'foo'
,
range
:
{
from
:
'now - 5h'
,
to
:
'now'
,
},
queries
:
[
{
query
:
'metric{test="a/b"}'
,
},
{
query
:
'super{foo="x/z"}'
,
},
],
};
expect
(
serializeStateToUrlParam
(
state
)).
toBe
(
'{"datasource":"foo","queries":[{"query":"metric{test=
\\
"a/b
\\
"}"},'
+
'{"query":"super{foo=
\\
"x/z
\\
"}"}],"range":{"from":"now - 5h","to":"now"}}'
);
});
});
describe
(
'interplay'
,
()
=>
{
it
(
'can parse the serialized state into the original state'
,
()
=>
{
const
state
=
{
...
DEFAULT_EXPLORE_STATE
,
datasourceName
:
'foo'
,
range
:
{
from
:
'now - 5h'
,
to
:
'now'
,
},
queries
:
[
{
query
:
'metric{test="a/b"}'
,
},
{
query
:
'super{foo="x/z"}'
,
},
],
};
const
serialized
=
serializeStateToUrlParam
(
state
);
const
parsed
=
parseUrlState
(
serialized
);
// Account for datasource vs datasourceName
const
{
datasource
,
...
rest
}
=
parsed
;
const
sameState
=
{
...
rest
,
datasource
:
DEFAULT_EXPLORE_STATE
.
datasource
,
datasourceName
:
datasource
,
};
expect
(
state
).
toMatchObject
(
sameState
);
});
});
});
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment