Skip to content
Next
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Switch to GitLab Next
Sign in / Register
Toggle navigation
Minds Mobile
Project
Project
Details
Activity
Releases
Cycle Analytics
Insights
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Locked Files
Issues
202
Issues
202
List
Boards
Labels
Service Desk
Milestones
Merge Requests
18
Merge Requests
18
Security & Compliance
Security & Compliance
Dependency List
Packages
Packages
List
Container Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Minds
Minds Mobile
Compare Revisions
b07ad242ed93f88c05fa3e3c17cd68720d2a2710...27168e5040a9b1207c5100bf0f1fccca37d818b5
Source
27168e5040a9b1207c5100bf0f1fccca37d818b5
Select Git revision
...
Target
b07ad242ed93f88c05fa3e3c17cd68720d2a2710
Select Git revision
Compare
Commits (2)
(feat) test base model permissions can method
· 8e4e62c2
Martin Santangelo
authored
1 hour ago
8e4e62c2
(feat) spec test closed channels and async view permission lose on channels screen
· 27168e50
Martin Santangelo
authored
1 hour ago
27168e50
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
562 additions
and
7 deletions
+562
-7
__tests__/channel/ChannelScreen.js
__tests__/channel/ChannelScreen.js
+31
-7
__tests__/channel/__snapshots__/ChannelScreen.js.snap
__tests__/channel/__snapshots__/ChannelScreen.js.snap
+498
-0
__tests__/common/BaseModel.js
__tests__/common/BaseModel.js
+33
-0
No files found.
__tests__/channel/ChannelScreen.js
View file @
27168e50
...
...
@@ -5,7 +5,8 @@ import { shallow } from 'enzyme';
import
ChannelScreen
from
'
../../src/channel/ChannelScreen
'
;
import
{
activitiesServiceFaker
}
from
'
../../__mocks__/fake/ActivitiesFaker
'
;
import
userFaker
from
'
../../__mocks__/fake/channel/UserFactory
'
import
UserModel
from
'
../../src/channel/UserModel
'
;
import
UserModel
,
{
USER_MODE_CLOSED
,
USER_MODE_OPEN
}
from
'
../../src/channel/UserModel
'
;
import
featuresService
from
'
../../src/common/services/features.service
'
;
jest
.
mock
(
'
../../src/common/helpers/abortableFetch
'
);
jest
.
mock
(
'
../../src/newsfeed/ActivityModel
'
);
...
...
@@ -34,7 +35,7 @@ describe('Channel screen component', () => {
activity
.
wire_totals
=
{
tokens
:
20
};
activity
.
impressions
=
20
;
navigation
=
{
navigate
:
jest
.
fn
()
};
navigation
=
{
navigate
:
jest
.
fn
()
,
goBack
:
jest
.
fn
()
};
navigation
.
state
=
{
params
:
{
entity
:
activity
...
...
@@ -60,7 +61,6 @@ describe('Channel screen component', () => {
<
ChannelScreen
.
wrappedComponent
channel
=
{
channel
}
navigation
=
{
navigation
}
/
>
);
screen
.
update
();
});
it
(
'
should renders correctly
'
,
()
=>
{
...
...
@@ -68,8 +68,7 @@ describe('Channel screen component', () => {
expect
(
screen
).
toMatchSnapshot
();
});
it
(
'
should have the expectedComponents while loading, also check newsfeed
'
,
async
()
=>
{
screen
.
update
();
it
(
'
should have the expected components while loading, also check newsfeed
'
,
async
()
=>
{
expect
(
screen
.
find
(
'
FeedList
'
)).
toHaveLength
(
1
);
let
render
=
screen
.
dive
();
...
...
@@ -77,8 +76,7 @@ describe('Channel screen component', () => {
expect
(
screen
.
find
(
'
CaptureFab
'
)).
toHaveLength
(
1
);
});
it
(
'
should have the expectedComponents while loading, also check flatlist for blocked
'
,
async
()
=>
{
it
(
'
should have the expected components while loading, also check flatlist for blocked
'
,
async
()
=>
{
channelStore
.
channel
.
blocked
=
true
;
...
...
@@ -90,4 +88,30 @@ describe('Channel screen component', () => {
expect
(
screen
.
find
(
'
CaptureFab
'
)).
toHaveLength
(
1
);
});
it
(
'
should show closed channel message
'
,
async
()
=>
{
channelStore
.
channel
.
blocked
=
false
;
channelStore
.
channel
.
mode
=
USER_MODE_CLOSED
;
await
screen
.
update
();
expect
(
screen
).
toMatchSnapshot
();
});
it
(
'
should navigate back if the the VIEW permissions are removed
'
,
async
()
=>
{
channelStore
.
channel
.
mode
=
USER_MODE_OPEN
;
// force permissions feature flag
featuresService
.
features
=
{
permissions
:
true
};
channelStore
.
channel
.
setPermissions
({
permissions
:[]});
await
screen
.
update
();
expect
(
navigation
.
goBack
).
toBeCalled
();
});
});
\ No newline at end of file
This diff is collapsed.
Click to expand it.
__tests__/channel/__snapshots__/ChannelScreen.js.snap
View file @
27168e50
This diff is collapsed.
Click to expand it.
__tests__/common/BaseModel.js
0 → 100644
View file @
27168e50
import
BaseModel
from
'
../../src/common/BaseModel
'
;
import
featuresService
from
'
../../src/common/services/features.service
'
;
describe
(
'
base model
'
,
()
=>
{
beforeEach
(()
=>
{
});
it
(
'
should set and validate permissions
'
,
()
=>
{
featuresService
.
features
=
{
permissions
:
true
};
const
data
=
{
permissions
:
[
'
permissions1
'
,
'
permissions2
'
,
'
permissions3
'
,
]
}
const
model
=
new
BaseModel
();
model
.
setPermissions
(
data
);
// should validate permissions
expect
(
model
.
can
(
'
permissions1
'
)).
toBe
(
true
);
expect
(
model
.
can
(
'
permissions2
'
)).
toBe
(
true
);
expect
(
model
.
can
(
'
permissions3
'
)).
toBe
(
true
);
expect
(
model
.
can
(
'
permissions4
'
)).
toBe
(
false
);
});
});
\ No newline at end of file
This diff is collapsed.
Click to expand it.