Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
Metabase
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Engineering Digital Service
Metabase
Commits
084fa781
Unverified
Commit
084fa781
authored
2 years ago
by
Ariya Hidayat
Committed by
GitHub
2 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Unit tests for getTemplateTagsForParameters (#23496)
parent
7f246b7e
Loading
Loading
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
frontend/src/metabase/parameters/utils/cards.unit.spec.js
+59
-0
59 additions, 0 deletions
frontend/src/metabase/parameters/utils/cards.unit.spec.js
with
59 additions
and
0 deletions
frontend/src/metabase/parameters/utils/cards.unit.spec.js
+
59
−
0
View file @
084fa781
import
{
import
{
getTemplateTagsForParameters
,
getTemplateTagParameters
,
getTemplateTagParameters
,
remapParameterValuesToTemplateTags
,
remapParameterValuesToTemplateTags
,
}
from
"
./cards
"
;
}
from
"
./cards
"
;
describe
(
"
parameters/utils/cards
"
,
()
=>
{
describe
(
"
parameters/utils/cards
"
,
()
=>
{
describe
(
"
getTemplateTagsForParameters
"
,
()
=>
{
it
(
"
should return an empty array for an invalid card
"
,
()
=>
{
expect
(
getTemplateTagsForParameters
({})).
toEqual
([]);
});
it
(
"
should return an empty array for a non-native query
"
,
()
=>
{
const
card
=
{
dataset_query
:
{
type
:
"
query
"
,
},
};
expect
(
getTemplateTagsForParameters
(
card
)).
toEqual
([]);
});
it
(
"
should return an empty array for a non-parametrized query
"
,
()
=>
{
const
card
=
{
dataset_query
:
{
type
:
"
query
"
,
native
:
{
query
:
"
select * from PRODUCTS
"
,
},
},
};
expect
(
getTemplateTagsForParameters
(
card
)).
toEqual
([]);
});
it
(
"
should extract the template tags defining the parameters
"
,
()
=>
{
const
card
=
{
dataset_query
:
{
type
:
"
native
"
,
native
:
{
query
:
"
select * from PRODUCTS where RATING > {{stars}}
"
,
"
template-tags
"
:
{
stars
:
{
type
:
"
number
"
,
name
:
"
stars
"
,
id
:
"
xyz777
"
,
},
"
snippet: foo
"
:
{
type
:
"
snippet
"
,
id
:
"
abc123
"
,
name
:
"
snippet: foo
"
,
"
snippet-id
"
:
6
,
},
},
},
},
};
expect
(
getTemplateTagsForParameters
(
card
)).
toEqual
([
{
type
:
"
number
"
,
name
:
"
stars
"
,
id
:
"
xyz777
"
,
},
]);
});
});
describe
(
"
getTemplateTagParameters
"
,
()
=>
{
describe
(
"
getTemplateTagParameters
"
,
()
=>
{
let
tags
;
let
tags
;
beforeEach
(()
=>
{
beforeEach
(()
=>
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment