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
c42f292d
Unverified
Commit
c42f292d
authored
7 years ago
by
Kyle Doherty
Browse files
Options
Downloads
Patches
Plain Diff
add initial tests
parent
2f036a9f
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
frontend/test/pulse/pulse.unit.spec.js
+77
-0
77 additions, 0 deletions
frontend/test/pulse/pulse.unit.spec.js
with
77 additions
and
0 deletions
frontend/test/pulse/pulse.unit.spec.js
0 → 100644
+
77
−
0
View file @
c42f292d
import
React
from
'
react
'
import
{
shallow
}
from
'
enzyme
'
import
UserAvatar
from
'
metabase/components/UserAvatar
'
import
RecipientPicker
from
'
metabase/pulse/components/RecipientPicker
'
// We have to do some mocking here to avoid calls to GA and to Metabase settings
jest
.
mock
(
'
metabase/lib/settings
'
,
()
=>
({
get
:
()
=>
'
v
'
}))
global
.
ga
=
jest
.
fn
()
const
TEST_USERS
=
[
{
id
:
1
,
common_name
:
'
Barb
'
,
email
:
'
barb_holland@hawkins.mail
'
},
// w
{
id
:
2
,
common_name
:
'
Dustin
'
,
email
:
'
dustin_henderson@hawkinsav.club
'
},
// w
{
id
:
3
,
common_name
:
'
El
'
,
email
:
'
011@energy.gov
'
},
{
id
:
4
,
common_name
:
'
Lucas
'
,
email
:
'
lucas.sinclair@hawkins.mail
'
},
// w
{
id
:
5
,
common_name
:
'
Mike
'
,
email
:
'
dm_mike@hawkins.mail
'
},
// w
{
id
:
6
,
common_name
:
'
Nancy
'
,
email
:
''
},
{
id
:
7
,
common_name
:
'
Steve
'
,
email
:
''
},
{
id
:
8
,
common_name
:
'
Will
'
,
email
:
'
zombieboy@upside.down
'
},
// w
]
describe
(
'
recipient picker
'
,
()
=>
{
describe
(
'
filtering
'
,
()
=>
{
it
(
'
should properly filter users based on input
'
,
()
=>
{
const
wrapper
=
shallow
(
<
RecipientPicker
recipients
=
{[]}
users
=
{
TEST_USERS
}
isNewPulse
=
{
true
}
onRecipientsChange
=
{()
=>
alert
(
'
why?
'
)}
/
>
)
const
spy
=
jest
.
spyOn
(
wrapper
.
instance
(),
'
setInputValue
'
)
const
input
=
wrapper
.
find
(
'
input
'
)
// we should start off with no users
expect
(
wrapper
.
state
().
filteredUsers
.
length
).
toBe
(
0
)
// simulate typing 'w'
input
.
simulate
(
'
change
'
,
{
target
:
{
value
:
'
w
'
}})
expect
(
spy
).
toHaveBeenCalled
()
expect
(
wrapper
.
state
().
inputValue
).
toEqual
(
'
w
'
)
// 5 of the test users have a w in their name or email
expect
(
wrapper
.
state
().
filteredUsers
.
length
).
toBe
(
5
)
})
})
describe
(
'
recipient selection
'
,
()
=>
{
it
(
'
should allow the user to click to select a recipient
'
,
()
=>
{
const
spy
=
jest
.
fn
()
const
wrapper
=
shallow
(
<
RecipientPicker
recipients
=
{[]}
users
=
{
TEST_USERS
}
isNewPulse
=
{
true
}
onRecipientsChange
=
{
spy
}
/
>
)
const
input
=
wrapper
.
find
(
'
input
'
)
input
.
simulate
(
'
change
'
,
{
target
:
{
value
:
'
steve
'
}})
expect
(
wrapper
.
state
().
filteredUsers
.
length
).
toBe
(
1
)
const
user
=
wrapper
.
find
(
UserAvatar
).
closest
(
'
li
'
)
user
.
simulate
(
'
click
'
,
{
target
:
{}})
expect
(
spy
).
toHaveBeenCalled
()
})
})
})
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