Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
R
react-native-notifications
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Jira
Jira
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
冷佳娟
react-native-notifications
Commits
1d5f6b2d
Commit
1d5f6b2d
authored
Aug 03, 2019
by
Yogev Ben David
Committed by
GitHub
Aug 03, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #354 from wix/testCoverage
Add test coverage on iOS
parents
4674f8ec
dbf046ef
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
8 deletions
+30
-8
RNNotifications/RNNotifications.xcodeproj/project.pbxproj
RNNotifications/RNNotifications.xcodeproj/project.pbxproj
+0
-8
RNNotifications/RNNotificationsTests/RNNotificationEventHandlerTests.m
...ns/RNNotificationsTests/RNNotificationEventHandlerTests.m
+30
-0
No files found.
RNNotifications/RNNotifications.xcodeproj/project.pbxproj
View file @
1d5f6b2d
...
...
@@ -192,17 +192,9 @@
name
=
Products
;
sourceTree
=
"<group>"
;
};
50002A7222E8874F008F6742
/* Utils */
=
{
isa
=
PBXGroup
;
children
=
(
);
path
=
Utils
;
sourceTree
=
"<group>"
;
};
504D54BC22E4B83E0088F2E4
/* Integration */
=
{
isa
=
PBXGroup
;
children
=
(
50002A7222E8874F008F6742
/* Utils */
,
504D54BD22E4B8660088F2E4
/* RNBridgeModuleIntegrationTest.m */
,
50002A4C22E88266008F6742
/* RNCommandsHandlerIntegrationTest.m */
,
);
...
...
RNNotifications/RNNotificationsTests/RNNotificationEventHandlerTests.m
View file @
1d5f6b2d
...
...
@@ -68,6 +68,28 @@
[
_mockedNotificationCenter
verify
];
}
-
(
void
)
testDidReceiveNotificationResponse_ShouldEmitEvent
{
UNNotification
*
notification
=
[
self
createNotificationWithIdentifier
:
@"id"
andUserInfo
:@{
@"extraKey"
:
@"extraValue"
}];
UNNotificationResponse
*
response
=
[
self
createNotificationResponseWithIdentifier
:
@"id"
andNotification
:
notification
];
void
(
^
testBlock
)(
void
)
=
^
void
()
{};
[[
_mockedNotificationCenter
expect
]
postNotificationName
:
RNNotificationOpened
object
:[
OCMArg
any
]
userInfo
:
[
OCMArg
checkWithBlock
:
^
BOOL
(
id
obj
)
{
return
([[
obj
valueForKey
:
@"identifier"
]
isEqualToString
:
@"id"
]
&&
[[[
obj
valueForKey
:
@"payload"
]
valueForKey
:
@"extraKey"
]
isEqualToString
:
@"extraValue"
]);
}]];
[
_uut
didReceiveNotificationResponse
:
response
completionHandler
:
testBlock
];
[
_mockedNotificationCenter
verify
];
}
-
(
void
)
testDidReceiveNotificationResponse_ShouldSaveCompletionBlockToStore
{
UNNotification
*
notification
=
[
self
createNotificationWithIdentifier
:
@"id"
andUserInfo
:@{
@"extraKey"
:
@"extraValue"
}];
UNNotificationResponse
*
response
=
[
self
createNotificationResponseWithIdentifier
:
@"id"
andNotification
:
notification
];
void
(
^
testBlock
)(
void
)
=
^
void
()
{};
[
_uut
didReceiveNotificationResponse
:
response
completionHandler
:
testBlock
];
XCTAssertEqual
([
_store
getActionCompletionHandler
:
@"id"
],
testBlock
);
}
-
(
UNNotification
*
)
createNotificationWithIdentifier
:(
NSString
*
)
identifier
andUserInfo
:(
NSDictionary
*
)
userInfo
{
UNNotification
*
notification
=
[
OCMockObject
niceMockForClass
:[
UNNotification
class
]];
UNNotificationContent
*
content
=
[
OCMockObject
niceMockForClass
:[
UNNotificationContent
class
]];
...
...
@@ -79,6 +101,14 @@
return
notification
;
}
-
(
UNNotificationResponse
*
)
createNotificationResponseWithIdentifier
:(
NSString
*
)
identifier
andNotification
:(
UNNotification
*
)
notification
{
UNNotificationResponse
*
notificationResponse
=
[
OCMockObject
niceMockForClass
:[
UNNotificationResponse
class
]];
OCMStub
(
notificationResponse
.
actionIdentifier
).
andReturn
(
identifier
);
OCMStub
(
notificationResponse
.
notification
).
andReturn
(
notification
);
return
notificationResponse
;
}
@end
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