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
4908c56e
Commit
4908c56e
authored
Jul 25, 2019
by
yogevbd
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add test coverage on native iOS
parent
9d85c4f2
Changes
27
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
27 changed files
with
1156 additions
and
42 deletions
+1156
-42
RNNotifications/OCMock/NSNotificationCenter+OCMAdditions.h
RNNotifications/OCMock/NSNotificationCenter+OCMAdditions.h
+26
-0
RNNotifications/OCMock/OCMArg.h
RNNotifications/OCMock/OCMArg.h
+58
-0
RNNotifications/OCMock/OCMConstraint.h
RNNotifications/OCMock/OCMConstraint.h
+71
-0
RNNotifications/OCMock/OCMFunctions.h
RNNotifications/OCMock/OCMFunctions.h
+27
-0
RNNotifications/OCMock/OCMLocation.h
RNNotifications/OCMock/OCMLocation.h
+38
-0
RNNotifications/OCMock/OCMMacroState.h
RNNotifications/OCMock/OCMMacroState.h
+48
-0
RNNotifications/OCMock/OCMRecorder.h
RNNotifications/OCMock/OCMRecorder.h
+39
-0
RNNotifications/OCMock/OCMStubRecorder.h
RNNotifications/OCMock/OCMStubRecorder.h
+64
-0
RNNotifications/OCMock/OCMock.h
RNNotifications/OCMock/OCMock.h
+113
-0
RNNotifications/OCMock/OCMockObject.h
RNNotifications/OCMock/OCMockObject.h
+74
-0
RNNotifications/RNBridgeModule.m
RNNotifications/RNBridgeModule.m
+1
-0
RNNotifications/RNCommandsHandler.h
RNNotifications/RNCommandsHandler.h
+0
-1
RNNotifications/RNNotificationCenter.h
RNNotifications/RNNotificationCenter.h
+5
-1
RNNotifications/RNNotificationCenter.m
RNNotifications/RNNotificationCenter.m
+8
-14
RNNotifications/RNNotificationEventHandler.h
RNNotifications/RNNotificationEventHandler.h
+1
-1
RNNotifications/RNNotificationEventHandler.m
RNNotifications/RNNotificationEventHandler.m
+1
-1
RNNotifications/RNNotifications.m
RNNotifications/RNNotifications.m
+0
-1
RNNotifications/RNNotifications.xcodeproj/project.pbxproj
RNNotifications/RNNotifications.xcodeproj/project.pbxproj
+171
-5
RNNotifications/RNNotifications.xcodeproj/xcshareddata/xcschemes/RNNotifications.xcscheme
...xcodeproj/xcshareddata/xcschemes/RNNotifications.xcscheme
+127
-0
RNNotifications/RNNotificationsStore.h
RNNotifications/RNNotificationsStore.h
+3
-1
RNNotifications/RNNotificationsStore.m
RNNotifications/RNNotificationsStore.m
+10
-2
RNNotifications/RNNotificationsTests/Integration/RNBridgeModuleIntegrationTest.m
...icationsTests/Integration/RNBridgeModuleIntegrationTest.m
+25
-0
RNNotifications/RNNotificationsTests/Integration/RNCommandsHandlerIntegrationTest.m
...tionsTests/Integration/RNCommandsHandlerIntegrationTest.m
+89
-0
RNNotifications/RNNotificationsTests/RNNotificationEventHandlerTests.m
...ns/RNNotificationsTests/RNNotificationEventHandlerTests.m
+52
-0
RNNotifications/RNNotificationsTests/RNNotificationsStoreTests.m
...ications/RNNotificationsTests/RNNotificationsStoreTests.m
+69
-0
RNNotifications/libOCMock.a
RNNotifications/libOCMock.a
+0
-0
example/ios/NotificationsExampleApp.xcodeproj/xcshareddata/xcschemes/NotificationsExampleApp.xcscheme
...j/xcshareddata/xcschemes/NotificationsExampleApp.xcscheme
+36
-15
No files found.
RNNotifications/OCMock/NSNotificationCenter+OCMAdditions.h
0 → 100644
View file @
4908c56e
/*
* Copyright (c) 2009-2016 Erik Doernenburg and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
* not use these files except in compliance with the License. You may obtain
* a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*/
#import <Foundation/Foundation.h>
@class
OCObserverMockObject
;
@interface
NSNotificationCenter
(
OCMAdditions
)
-
(
void
)
addMockObserver
:(
OCObserverMockObject
*
)
notificationObserver
name
:(
NSString
*
)
notificationName
object
:(
id
)
notificationSender
;
@end
RNNotifications/OCMock/OCMArg.h
0 → 100644
View file @
4908c56e
/*
* Copyright (c) 2009-2016 Erik Doernenburg and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
* not use these files except in compliance with the License. You may obtain
* a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*/
#import <Foundation/Foundation.h>
@interface
OCMArg
:
NSObject
// constraining arguments
+
(
id
)
any
;
+
(
SEL
)
anySelector
;
+
(
void
*
)
anyPointer
;
+
(
id
__autoreleasing
*
)
anyObjectRef
;
+
(
id
)
isNil
;
+
(
id
)
isNotNil
;
+
(
id
)
isEqual
:(
id
)
value
;
+
(
id
)
isNotEqual
:(
id
)
value
;
+
(
id
)
isKindOfClass
:(
Class
)
cls
;
+
(
id
)
checkWithSelector
:(
SEL
)
selector
onObject
:(
id
)
anObject
;
+
(
id
)
checkWithBlock
:(
BOOL
(
^
)(
id
obj
))
block
;
// manipulating arguments
+
(
id
*
)
setTo
:(
id
)
value
;
+
(
void
*
)
setToValue
:(
NSValue
*
)
value
;
+
(
id
)
invokeBlock
;
+
(
id
)
invokeBlockWithArgs
:(
id
)
first
,...
NS_REQUIRES_NIL_TERMINATION
;
+
(
id
)
defaultValue
;
// internal use only
+
(
id
)
resolveSpecialValues
:(
NSValue
*
)
value
;
@end
#define OCMOCK_ANY [OCMArg any]
#if defined(__GNUC__) && !defined(__STRICT_ANSI__)
#define OCMOCK_VALUE(variable) \
({ __typeof__(variable) __v = (variable); [NSValue value:&__v withObjCType:@encode(__typeof__(__v))]; })
#else
#define OCMOCK_VALUE(variable) [NSValue value:&variable withObjCType:@encode(__typeof__(variable))]
#endif
RNNotifications/OCMock/OCMConstraint.h
0 → 100644
View file @
4908c56e
/*
* Copyright (c) 2007-2016 Erik Doernenburg and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
* not use these files except in compliance with the License. You may obtain
* a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*/
#import <Foundation/Foundation.h>
@interface
OCMConstraint
:
NSObject
+
(
instancetype
)
constraint
;
-
(
BOOL
)
evaluate
:(
id
)
value
;
// if you are looking for any, isNil, etc, they have moved to OCMArg
// try to use [OCMArg checkWith...] instead of the constraintWith... methods below
+
(
instancetype
)
constraintWithSelector
:(
SEL
)
aSelector
onObject
:(
id
)
anObject
;
+
(
instancetype
)
constraintWithSelector
:(
SEL
)
aSelector
onObject
:(
id
)
anObject
withValue
:(
id
)
aValue
;
@end
@interface
OCMAnyConstraint
:
OCMConstraint
@end
@interface
OCMIsNilConstraint
:
OCMConstraint
@end
@interface
OCMIsNotNilConstraint
:
OCMConstraint
@end
@interface
OCMIsNotEqualConstraint
:
OCMConstraint
{
@public
id
testValue
;
}
@end
@interface
OCMInvocationConstraint
:
OCMConstraint
{
@public
NSInvocation
*
invocation
;
}
@end
@interface
OCMBlockConstraint
:
OCMConstraint
{
BOOL
(
^
block
)(
id
);
}
-
(
instancetype
)
initWithConstraintBlock
:(
BOOL
(
^
)(
id
))
block
;
@end
#define CONSTRAINT(aSelector) [OCMConstraint constraintWithSelector:aSelector onObject:self]
#define CONSTRAINTV(aSelector, aValue) [OCMConstraint constraintWithSelector:aSelector onObject:self withValue:(aValue)]
RNNotifications/OCMock/OCMFunctions.h
0 → 100644
View file @
4908c56e
/*
* Copyright (c) 2014-2016 Erik Doernenburg and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
* not use these files except in compliance with the License. You may obtain
* a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*/
#import <Foundation/Foundation.h>
#if defined(__cplusplus)
#define OCMOCK_EXTERN extern "C"
#else
#define OCMOCK_EXTERN extern
#endif
OCMOCK_EXTERN
BOOL
OCMIsObjectType
(
const
char
*
objCType
);
RNNotifications/OCMock/OCMLocation.h
0 → 100644
View file @
4908c56e
/*
* Copyright (c) 2014-2016 Erik Doernenburg and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
* not use these files except in compliance with the License. You may obtain
* a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*/
#import <Foundation/Foundation.h>
#import "OCMFunctions.h"
@interface
OCMLocation
:
NSObject
{
id
testCase
;
NSString
*
file
;
NSUInteger
line
;
}
+
(
instancetype
)
locationWithTestCase
:(
id
)
aTestCase
file
:(
NSString
*
)
aFile
line
:(
NSUInteger
)
aLine
;
-
(
instancetype
)
initWithTestCase
:(
id
)
aTestCase
file
:(
NSString
*
)
aFile
line
:(
NSUInteger
)
aLine
;
-
(
id
)
testCase
;
-
(
NSString
*
)
file
;
-
(
NSUInteger
)
line
;
@end
OCMOCK_EXTERN
OCMLocation
*
OCMMakeLocation
(
id
testCase
,
const
char
*
file
,
int
line
);
RNNotifications/OCMock/OCMMacroState.h
0 → 100644
View file @
4908c56e
/*
* Copyright (c) 2014-2016 Erik Doernenburg and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
* not use these files except in compliance with the License. You may obtain
* a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*/
#import <Foundation/Foundation.h>
@class
OCMLocation
;
@class
OCMRecorder
;
@class
OCMStubRecorder
;
@class
OCMockObject
;
@interface
OCMMacroState
:
NSObject
{
OCMRecorder
*
recorder
;
}
+
(
void
)
beginStubMacro
;
+
(
OCMStubRecorder
*
)
endStubMacro
;
+
(
void
)
beginExpectMacro
;
+
(
OCMStubRecorder
*
)
endExpectMacro
;
+
(
void
)
beginRejectMacro
;
+
(
OCMStubRecorder
*
)
endRejectMacro
;
+
(
void
)
beginVerifyMacroAtLocation
:(
OCMLocation
*
)
aLocation
;
+
(
void
)
endVerifyMacro
;
+
(
OCMMacroState
*
)
globalState
;
-
(
OCMRecorder
*
)
recorder
;
-
(
void
)
switchToClassMethod
;
@end
RNNotifications/OCMock/OCMRecorder.h
0 → 100644
View file @
4908c56e
/*
* Copyright (c) 2014-2016 Erik Doernenburg and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
* not use these files except in compliance with the License. You may obtain
* a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*/
#import <Foundation/Foundation.h>
@class
OCMockObject
;
@class
OCMInvocationMatcher
;
@interface
OCMRecorder
:
NSProxy
{
OCMockObject
*
mockObject
;
OCMInvocationMatcher
*
invocationMatcher
;
}
-
(
instancetype
)
init
;
-
(
instancetype
)
initWithMockObject
:(
OCMockObject
*
)
aMockObject
;
-
(
void
)
setMockObject
:(
OCMockObject
*
)
aMockObject
;
-
(
OCMInvocationMatcher
*
)
invocationMatcher
;
-
(
id
)
classMethod
;
-
(
id
)
ignoringNonObjectArgs
;
@end
RNNotifications/OCMock/OCMStubRecorder.h
0 → 100644
View file @
4908c56e
/*
* Copyright (c) 2004-2016 Erik Doernenburg and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
* not use these files except in compliance with the License. You may obtain
* a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*/
#import <OCMock/OCMRecorder.h>
#import <OCMock/OCMFunctions.h>
#import <objc/runtime.h>
@interface
OCMStubRecorder
:
OCMRecorder
-
(
id
)
andReturn
:(
id
)
anObject
;
-
(
id
)
andReturnValue
:(
NSValue
*
)
aValue
;
-
(
id
)
andThrow
:(
NSException
*
)
anException
;
-
(
id
)
andPost
:(
NSNotification
*
)
aNotification
;
-
(
id
)
andCall
:(
SEL
)
selector
onObject
:(
id
)
anObject
;
-
(
id
)
andDo
:(
void
(
^
)(
NSInvocation
*
invocation
))
block
;
-
(
id
)
andForwardToRealObject
;
@end
@interface
OCMStubRecorder
(
Properties
)
#define andReturn(aValue) _andReturn(({ \
__typeof__(aValue) _val = (aValue); \
NSValue *_nsval = [NSValue value:&_val withObjCType:@encode(__typeof__(_val))]; \
if (OCMIsObjectType(@encode(__typeof(_val)))) { \
objc_setAssociatedObject(_nsval, "OCMAssociatedBoxedValue", *(__unsafe_unretained id *) (void *) &_val, OBJC_ASSOCIATION_RETAIN); \
} \
_nsval; \
}))
@property
(
nonatomic
,
readonly
)
OCMStubRecorder
*
(
^
_andReturn
)(
NSValue
*
);
#define andThrow(anException) _andThrow(anException)
@property
(
nonatomic
,
readonly
)
OCMStubRecorder
*
(
^
_andThrow
)(
NSException
*
);
#define andPost(aNotification) _andPost(aNotification)
@property
(
nonatomic
,
readonly
)
OCMStubRecorder
*
(
^
_andPost
)(
NSNotification
*
);
#define andCall(anObject, aSelector) _andCall(anObject, aSelector)
@property
(
nonatomic
,
readonly
)
OCMStubRecorder
*
(
^
_andCall
)(
id
,
SEL
);
#define andDo(aBlock) _andDo(aBlock)
@property
(
nonatomic
,
readonly
)
OCMStubRecorder
*
(
^
_andDo
)(
void
(
^
)(
NSInvocation
*
));
#define andForwardToRealObject() _andForwardToRealObject()
@property
(
nonatomic
,
readonly
)
OCMStubRecorder
*
(
^
_andForwardToRealObject
)(
void
);
@end
RNNotifications/OCMock/OCMock.h
0 → 100644
View file @
4908c56e
/*
* Copyright (c) 2004-2016 Erik Doernenburg and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
* not use these files except in compliance with the License. You may obtain
* a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*/
#import <OCMock/OCMockObject.h>
#import <OCMock/OCMRecorder.h>
#import <OCMock/OCMStubRecorder.h>
#import <OCMock/OCMConstraint.h>
#import <OCMock/OCMArg.h>
#import <OCMock/OCMLocation.h>
#import <OCMock/OCMMacroState.h>
#import <OCMock/NSNotificationCenter+OCMAdditions.h>
#import <OCMock/OCMFunctions.h>
#define OCMClassMock(cls) [OCMockObject niceMockForClass:cls]
#define OCMStrictClassMock(cls) [OCMockObject mockForClass:cls]
#define OCMProtocolMock(protocol) [OCMockObject niceMockForProtocol:protocol]
#define OCMStrictProtocolMock(protocol) [OCMockObject mockForProtocol:protocol]
#define OCMPartialMock(obj) [OCMockObject partialMockForObject:obj]
#define OCMObserverMock() [OCMockObject observerMock]
#define OCMStub(invocation) \
({ \
_OCMSilenceWarnings( \
[OCMMacroState beginStubMacro]; \
OCMStubRecorder *recorder = nil; \
@try{ \
invocation; \
}@finally{ \
recorder = [OCMMacroState endStubMacro]; \
} \
recorder; \
); \
})
#define OCMExpect(invocation) \
({ \
_OCMSilenceWarnings( \
[OCMMacroState beginExpectMacro]; \
OCMStubRecorder *recorder = nil; \
@try{ \
invocation; \
}@finally{ \
recorder = [OCMMacroState endExpectMacro]; \
} \
recorder; \
); \
})
#define OCMReject(invocation) \
({ \
_OCMSilenceWarnings( \
[OCMMacroState beginRejectMacro]; \
OCMStubRecorder *recorder = nil; \
@try{ \
invocation; \
}@finally{ \
recorder = [OCMMacroState endRejectMacro]; \
} \
recorder; \
); \
})
#define ClassMethod(invocation) \
_OCMSilenceWarnings( \
[[OCMMacroState globalState] switchToClassMethod]; \
invocation; \
);
#define OCMVerifyAll(mock) [mock verifyAtLocation:OCMMakeLocation(self, __FILE__, __LINE__)]
#define OCMVerifyAllWithDelay(mock, delay) [mock verifyWithDelay:delay atLocation:OCMMakeLocation(self, __FILE__, __LINE__)]
#define OCMVerify(invocation) \
({ \
_OCMSilenceWarnings( \
[OCMMacroState beginVerifyMacroAtLocation:OCMMakeLocation(self, __FILE__, __LINE__)]; \
@try{ \
invocation; \
}@finally{ \
[OCMMacroState endVerifyMacro]; \
} \
); \
})
#define _OCMSilenceWarnings(macro) \
({ \
_Pragma("clang diagnostic push") \
_Pragma("clang diagnostic ignored \"-Wunused-value\"") \
_Pragma("clang diagnostic ignored \"-Wunused-getter-return-value\"") \
macro \
_Pragma("clang diagnostic pop") \
})
RNNotifications/OCMock/OCMockObject.h
0 → 100644
View file @
4908c56e
/*
* Copyright (c) 2004-2016 Erik Doernenburg and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
* not use these files except in compliance with the License. You may obtain
* a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*/
#import <Foundation/Foundation.h>
@class
OCMLocation
;
@class
OCMInvocationStub
;
@class
OCMStubRecorder
;
@class
OCMInvocationMatcher
;
@class
OCMInvocationExpectation
;
@interface
OCMockObject
:
NSProxy
{
BOOL
isNice
;
BOOL
expectationOrderMatters
;
NSMutableArray
*
stubs
;
NSMutableArray
*
expectations
;
NSMutableArray
*
exceptions
;
NSMutableArray
*
invocations
;
}
+
(
id
)
mockForClass
:(
Class
)
aClass
;
+
(
id
)
mockForProtocol
:(
Protocol
*
)
aProtocol
;
+
(
id
)
partialMockForObject
:(
NSObject
*
)
anObject
;
+
(
id
)
niceMockForClass
:(
Class
)
aClass
;
+
(
id
)
niceMockForProtocol
:(
Protocol
*
)
aProtocol
;
+
(
id
)
observerMock
;
-
(
instancetype
)
init
;
-
(
void
)
setExpectationOrderMatters
:(
BOOL
)
flag
;
-
(
id
)
stub
;
-
(
id
)
expect
;
-
(
id
)
reject
;
-
(
id
)
verify
;
-
(
id
)
verifyAtLocation
:(
OCMLocation
*
)
location
;
-
(
void
)
verifyWithDelay
:(
NSTimeInterval
)
delay
;
-
(
void
)
verifyWithDelay
:(
NSTimeInterval
)
delay
atLocation
:(
OCMLocation
*
)
location
;
-
(
void
)
stopMocking
;
// internal use only
-
(
void
)
addStub
:(
OCMInvocationStub
*
)
aStub
;
-
(
void
)
addExpectation
:(
OCMInvocationExpectation
*
)
anExpectation
;
-
(
BOOL
)
handleInvocation
:(
NSInvocation
*
)
anInvocation
;
-
(
void
)
handleUnRecordedInvocation
:(
NSInvocation
*
)
anInvocation
;
-
(
BOOL
)
handleSelector
:(
SEL
)
sel
;
-
(
void
)
verifyInvocation
:(
OCMInvocationMatcher
*
)
matcher
;
-
(
void
)
verifyInvocation
:(
OCMInvocationMatcher
*
)
matcher
atLocation
:(
OCMLocation
*
)
location
;
@end
RNNotifications/RNBridgeModule.m
View file @
4908c56e
...
...
@@ -3,6 +3,7 @@
#import "RCTConvert+RNNotifications.h"
#import "RNNotificationsStore.h"
#import <React/RCTBridgeDelegate.h>
#import <React/RCTBridge.h>
@implementation
RNBridgeModule
{
RNCommandsHandler
*
_commandsHandler
;
...
...
RNNotifications/RNCommandsHandler.h
View file @
4908c56e
#import <Foundation/Foundation.h>
#import <React/RCTBridge.h>
#import "RNNotificationCenter.h"
@interface
RNCommandsHandler
:
NSObject
...
...
RNNotifications/RNNotificationCenter.h
View file @
4908c56e
#import <Foundation/Foundation.h>
#import <React/RCTBridge.h>
typedef
void
(
^
RCTPromiseResolveBlock
)(
id
result
);
typedef
void
(
^
RCTResponseSenderBlock
)(
NSArray
*
response
);
typedef
void
(
^
RCTPromiseRejectBlock
)(
NSString
*
code
,
NSString
*
message
,
NSError
*
error
);
@import
UserNotifications
;
@interface
RNNotificationCenter
:
NSObject
...
...
RNNotifications/RNNotificationCenter.m
View file @
4908c56e
...
...
@@ -15,20 +15,14 @@
[[
UNUserNotificationCenter
currentNotificationCenter
]
setNotificationCategories
:
categories
];
UNAuthorizationOptions
authOptions
=
(
UNAuthorizationOptionBadge
|
UNAuthorizationOptionSound
|
UNAuthorizationOptionAlert
);
[
UNUserNotificationCenter
.
currentNotificationCenter
requestAuthorizationWithOptions
:
authOptions
completionHandler
:
^
(
BOOL
granted
,
NSError
*
_Nullable
error
)
{
if
(
error
)
{
}
else
{
if
(
granted
)
{
[
UNUserNotificationCenter
.
currentNotificationCenter
getNotificationSettingsWithCompletionHandler
:
^
(
UNNotificationSettings
*
_Nonnull
settings
)
{
if
(
settings
.
authorizationStatus
==
UNAuthorizationStatusAuthorized
)
{
dispatch_async
(
dispatch_get_main_queue
(),
^
{
[[
UIApplication
sharedApplication
]
registerForRemoteNotifications
];
});
}
}];
}
else
{
}
if
(
!
error
&&
granted
)
{
[
UNUserNotificationCenter
.
currentNotificationCenter
getNotificationSettingsWithCompletionHandler
:
^
(
UNNotificationSettings
*
_Nonnull
settings
)
{
if
(
settings
.
authorizationStatus
==
UNAuthorizationStatusAuthorized
)
{
dispatch_async
(
dispatch_get_main_queue
(),
^
{
[[
UIApplication
sharedApplication
]
registerForRemoteNotifications
];
});
}
}];
}
}];
}
...
...
RNNotifications/RNNotificationEventHandler.h
View file @
4908c56e
...
...
@@ -11,6 +11,6 @@
-
(
void
)
didFailToRegisterForRemoteNotificationsWithError
:(
NSError
*
)
error
;
-
(
void
)
didReceiveForegroundNotification
:(
UNNotification
*
)
notification
withCompletionHandler
:(
void
(
^
)(
UNNotificationPresentationOptions
))
completionHandler
;
-
(
void
)
didReceiveNotificationResponse
:(
UNNotificationResponse
*
)
notificationResponse
completionHandler
:(
void
(
^
)())
completionHandler
;
-
(
void
)
didReceiveNotificationResponse
:(
UNNotificationResponse
*
)
notificationResponse
completionHandler
:(
void
(
^
)(
void
))
completionHandler
;
@end
RNNotifications/RNNotificationEventHandler.m
View file @
4908c56e
...
...
@@ -28,7 +28,7 @@
[
RNEventEmitter
sendEvent
:
RNNotificationReceivedForeground
body
:[
RNNotificationParser
parseNotification
:
notification
]];
}
-
(
void
)
didReceiveNotificationResponse
:(
UNNotificationResponse
*
)
response
completionHandler
:(
void
(
^
)())
completionHandler
{
-
(
void
)
didReceiveNotificationResponse
:(
UNNotificationResponse
*
)
response
completionHandler
:(
void
(
^
)(
void
))
completionHandler
{
[
_store
setActionCompletionHandler
:
completionHandler
withCompletionKey
:
response
.
notification
.
request
.
identifier
];
[
RNEventEmitter
sendEvent
:
RNNotificationOpened
body
:[
RNNotificationParser
parseNotificationResponse
:
response
]];
}
...
...
RNNotifications/RNNotifications.m
View file @
4908c56e
#import <UIKit/UIKit.h>
#import <PushKit/PushKit.h>
#import <React/RCTBridge.h>
#import "RNNotifications.h"
#import "RNNotificationCenterListener.h"
#import "RNPushKit.h"
...
...
RNNotifications/RNNotifications.xcodeproj/project.pbxproj
View file @
4908c56e
This diff is collapsed.
Click to expand it.
RNNotifications/RNNotifications.xcodeproj/xcshareddata/xcschemes/RNNotifications.xcscheme
0 → 100644
View file @
4908c56e
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion =
"1010"
version =
"1.3"
>
<BuildAction
parallelizeBuildables =
"NO"
buildImplicitDependencies =
"YES"
>
<BuildActionEntries>
<BuildActionEntry
buildForTesting =
"YES"
buildForRunning =
"YES"
buildForProfiling =
"YES"
buildForArchiving =
"YES"
buildForAnalyzing =
"YES"
>
<BuildableReference
BuildableIdentifier =
"primary"
BlueprintIdentifier =
"3D3C04B91DE3340900C268FA"
BuildableName =
"libyoga.a"
BlueprintName =
"yoga"
ReferencedContainer =
"container:../node_modules/react-native/React/React.xcodeproj"
>
</BuildableReference>
</BuildActionEntry>
<BuildActionEntry
buildForTesting =
"YES"
buildForRunning =
"YES"
buildForProfiling =
"YES"
buildForArchiving =
"YES"
buildForAnalyzing =
"YES"
>
<BuildableReference
BuildableIdentifier =
"primary"
BlueprintIdentifier =
"83CBBA2D1A601D0E00E9B192"
BuildableName =
"libReact.a"
BlueprintName =
"React"
ReferencedContainer =
"container:../node_modules/react-native/React/React.xcodeproj"
>
</BuildableReference>
</BuildActionEntry>
<BuildActionEntry
buildForTesting =
"YES"
buildForRunning =
"YES"
buildForProfiling =
"YES"
buildForArchiving =
"YES"
buildForAnalyzing =
"YES"
>
<BuildableReference
BuildableIdentifier =
"primary"
BlueprintIdentifier =
"58B511DA1A9E6C8500147676"
BuildableName =
"libRNNotifications.a"
BlueprintName =
"RNNotifications"
ReferencedContainer =
"container:RNNotifications.xcodeproj"
>
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration =
"Debug"
selectedDebuggerIdentifier =
"Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier =
"Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv =
"YES"
>
<Testables>
<TestableReference
skipped =
"NO"
>
<BuildableReference
BuildableIdentifier =
"primary"
BlueprintIdentifier =
"508CE7C722D12B2600357815"
BuildableName =
"RNNotificationsTests.xctest"
BlueprintName =
"RNNotificationsTests"
ReferencedContainer =
"container:RNNotifications.xcodeproj"
>
</BuildableReference>
</TestableReference>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier =
"primary"
BlueprintIdentifier =
"58B511DA1A9E6C8500147676"
BuildableName =
"libRNNotifications.a"
BlueprintName =
"RNNotifications"
ReferencedContainer =
"container:RNNotifications.xcodeproj"
>
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration =
"Debug"
selectedDebuggerIdentifier =
"Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier =
"Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle =
"0"
useCustomWorkingDirectory =
"NO"
ignoresPersistentStateOnLaunch =
"NO"
debugDocumentVersioning =
"YES"
debugServiceExtension =
"internal"
allowLocationSimulation =
"YES"
>
<MacroExpansion>
<BuildableReference
BuildableIdentifier =
"primary"
BlueprintIdentifier =
"58B511DA1A9E6C8500147676"
BuildableName =
"libRNNotifications.a"
BlueprintName =
"RNNotifications"
ReferencedContainer =
"container:RNNotifications.xcodeproj"
>
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration =
"Release"
shouldUseLaunchSchemeArgsEnv =
"YES"
savedToolIdentifier =
""
useCustomWorkingDirectory =
"NO"
debugDocumentVersioning =
"YES"
>
<MacroExpansion>
<BuildableReference
BuildableIdentifier =
"primary"
BlueprintIdentifier =
"58B511DA1A9E6C8500147676"
BuildableName =
"libRNNotifications.a"
BlueprintName =
"RNNotifications"
ReferencedContainer =
"container:RNNotifications.xcodeproj"
>
</BuildableReference>
</MacroExpansion>
</ProfileAction>
<AnalyzeAction
buildConfiguration =
"Debug"
>
</AnalyzeAction>
<ArchiveAction
buildConfiguration =
"Release"
revealArchiveInOrganizer =
"YES"
>
</ArchiveAction>
</Scheme>
RNNotifications/RNNotificationsStore.h
View file @
4908c56e
...
...
@@ -9,8 +9,10 @@
-
(
void
)
completeAction
:(
NSString
*
)
completionKey
;
-
(
void
)
completePresentation
:(
NSString
*
)
completionKey
withPresentationOptions
:(
UNNotificationPresentationOptions
)
presentationOptions
;
-
(
void
)
setActionCompletionHandler
:(
void
(
^
)())
completionHandler
withCompletionKey
:(
NSString
*
)
completionKey
;
-
(
void
)
setActionCompletionHandler
:(
void
(
^
)(
void
))
completionHandler
withCompletionKey
:(
NSString
*
)
completionKey
;
-
(
void
)
setPresentationCompletionHandler
:(
void
(
^
)(
UNNotificationPresentationOptions
))
completionHandler
withCompletionKey
:(
NSString
*
)
completionKey
;
-
(
void
(
^
)(
void
))
getActionCompletionHandler
:(
NSString
*
)
key
;
-
(
void
(
^
)(
UNNotificationPresentationOptions
))
getPresentationCompletionHandler
:(
NSString
*
)
key
;
@end
RNNotifications/RNNotificationsStore.m
View file @
4908c56e
...
...
@@ -21,7 +21,7 @@ NSMutableDictionary* _presentationCompletionHandlers;
return
self
;
}
-
(
void
)
setActionCompletionHandler
:(
void
(
^
)())
completionHandler
withCompletionKey
:(
NSString
*
)
completionKey
{
-
(
void
)
setActionCompletionHandler
:(
void
(
^
)(
void
))
completionHandler
withCompletionKey
:(
NSString
*
)
completionKey
{
_actionCompletionHandlers
[
completionKey
]
=
completionHandler
;
}
...
...
@@ -29,6 +29,14 @@ NSMutableDictionary* _presentationCompletionHandlers;
_presentationCompletionHandlers
[
completionKey
]
=
completionHandler
;
}
-
(
void
(
^
)(
void
))
getActionCompletionHandler
:(
NSString
*
)
key
{
return
_actionCompletionHandlers
[
key
];
}
-
(
void
(
^
)(
UNNotificationPresentationOptions
))
getPresentationCompletionHandler
:(
NSString
*
)
key
{
return
_presentationCompletionHandlers
[
key
];
}
-
(
void
)
completeAction
:(
NSString
*
)
completionKey
{
void
(
^
completionHandler
)()
=
(
void
(
^
)())[
_actionCompletionHandlers
valueForKey
:
completionKey
];
if
(
completionHandler
)
{
...
...
@@ -41,7 +49,7 @@ NSMutableDictionary* _presentationCompletionHandlers;
void
(
^
completionHandler
)()
=
(
void
(
^
)(
UNNotificationPresentationOptions
))[
_presentationCompletionHandlers
valueForKey
:
completionKey
];
if
(
completionHandler
)
{
completionHandler
(
presentationOptions
);
[
_
ac
tionCompletionHandlers
removeObjectForKey
:
completionKey
];
[
_
presenta
tionCompletionHandlers
removeObjectForKey
:
completionKey
];
}
}
...
...
RNNotifications/RNNotificationsTests/Integration/RNBridgeModuleIntegrationTest.m
0 → 100644
View file @
4908c56e
#import <XCTest/XCTest.h>
#import "RNBridgeModule.h"
#import <OCMock/OCMock.h>
@interface
RNBridgeModuleIntegrationTest
:
XCTestCase
@property
(
nonatomic
,
strong
)
RNBridgeModule
*
bridgeModule
;
@end
@implementation
RNBridgeModuleIntegrationTest
-
(
void
)
setUp
{
}
-
(
void
)
tearDown
{
}
-
(
void
)
testRequestPermissionsWithCategories
{
}
@end
RNNotifications/RNNotificationsTests/Integration/RNCommandsHandlerIntegrationTest.m
0 → 100644
View file @
4908c56e
#import <XCTest/XCTest.h>
#import <OCMock/OCMock.h>
#import <objc/runtime.h>
#import "RNCommandsHandler.h"
#import "RNNotificationsStore.h"
@interface
RNCommandsHandlerIntegrationTest
:
XCTestCase
@property
(
nonatomic
,
retain
)
RNCommandsHandler
*
uut
;
@property
(
nonatomic
,
retain
)
id
notificationCenter
;
@property
(
nonatomic
,
retain
)
id
mockUserNotifications
;
@end
@implementation
RNCommandsHandlerIntegrationTest
-
(
void
)
setUp
{
_mockUserNotifications
=
[
OCMockObject
mockForProtocol
:[
self
getMockUserNotificationCenterProtocol
]];
id
notificationCenterMock
=
OCMClassMock
([
UNUserNotificationCenter
class
]);
OCMStub
(
ClassMethod
([
notificationCenterMock
currentNotificationCenter
])).
andReturn
(
_mockUserNotifications
);
UIApplication
*
sharedApplication
=
[
OCMockObject
mockForClass
:[
UIApplication
class
]];
id
mockedApplicationClass
=
OCMClassMock
([
UIApplication
class
]);
OCMStub
(
ClassMethod
([
mockedApplicationClass
sharedApplication
])).
andReturn
(
sharedApplication
);
_uut
=
[
RNCommandsHandler
new
];
_notificationCenter
=
[
UNUserNotificationCenter
currentNotificationCenter
];
}
-
(
void
)
testRequestPermissionsWithCategories_userAuthorizedPermissions
{
NSArray
*
json
=
@[@{
@"identifier"
:
@"identifier"
}];
UNAuthorizationOptions
authOptions
=
(
UNAuthorizationOptionBadge
|
UNAuthorizationOptionSound
|
UNAuthorizationOptionAlert
);
UNNotificationSettings
*
settings
=
[
UNNotificationSettings
new
];
[
settings
setValue
:
@
(
UNAuthorizationStatusAuthorized
)
forKey
:
@"authorizationStatus"
];
[[
_notificationCenter
expect
]
setNotificationCategories
:[
OCMArg
any
]];
[[
_notificationCenter
expect
]
requestAuthorizationWithOptions
:
authOptions
completionHandler
:[
OCMArg
invokeBlockWithArgs
:
@
(
YES
),
[
NSNull
null
],
nil
]];
[[
_notificationCenter
expect
]
getNotificationSettingsWithCompletionHandler
:[
OCMArg
invokeBlockWithArgs
:
settings
,
nil
]];
[[(
id
)[
UIApplication
sharedApplication
]
expect
]
registerForRemoteNotifications
];
[
_uut
requestPermissionsWithCategories
:
json
];
[
_notificationCenter
verify
];
}
-
(
void
)
testRequestPermissionsWithCategories_userDeniedPermissions
{
NSArray
*
json
=
@[@{
@"identifier"
:
@"identifier"
}];
UNAuthorizationOptions
authOptions
=
(
UNAuthorizationOptionBadge
|
UNAuthorizationOptionSound
|
UNAuthorizationOptionAlert
);
UNNotificationSettings
*
settings
=
[
UNNotificationSettings
new
];
[
settings
setValue
:
@
(
UNAuthorizationStatusDenied
)
forKey
:
@"authorizationStatus"
];
[[
_notificationCenter
expect
]
setNotificationCategories
:[
OCMArg
any
]];
[[
_notificationCenter
expect
]
requestAuthorizationWithOptions
:
authOptions
completionHandler
:[
OCMArg
invokeBlockWithArgs
:
@
(
YES
),
[
NSNull
null
],
nil
]];
[[
_notificationCenter
expect
]
getNotificationSettingsWithCompletionHandler
:[
OCMArg
invokeBlockWithArgs
:
settings
,
nil
]];
[[(
id
)[
UIApplication
sharedApplication
]
reject
]
registerForRemoteNotifications
];
[
_uut
requestPermissionsWithCategories
:
json
];
[
_notificationCenter
verify
];
}
-
(
void
)
testGetInitialNotification
{
NSDictionary
*
initialNotification
=
@{};
[[
RNNotificationsStore
sharedInstance
]
setInitialNotification
:
initialNotification
];
[
self
.
uut
getInitialNotification
:
^
(
id
result
)
{
XCTAssertEqual
(
result
,
initialNotification
);
}
reject
:
^
(
NSString
*
code
,
NSString
*
message
,
NSError
*
error
)
{
}];
}
-
(
Protocol
*
)
getMockUserNotificationCenterProtocol
{
Protocol
*
aProtocol
=
objc_getProtocol
(
"MockUserNotificationCenter"
);
if
(
!
aProtocol
)
{
aProtocol
=
objc_allocateProtocol
(
"MockUserNotificationCenter"
);
unsigned
int
methodCount
=
0
;
Method
*
methods
=
class_copyMethodList
([
UNUserNotificationCenter
class
],
&
methodCount
);
for
(
unsigned
int
i
=
0
;
i
<
methodCount
;
i
++
)
{
Method
method
=
methods
[
i
];
protocol_addMethodDescription
(
aProtocol
,
method_getName
(
method
),
method_getTypeEncoding
(
method
),
YES
,
YES
);
}
free
(
methods
);
objc_registerProtocol
(
aProtocol
);
}
return
aProtocol
;
}
@end
RNNotifications/RNNotificationsTests/RNNotificationEventHandlerTests.m
0 → 100644
View file @
4908c56e
#import <XCTest/XCTest.h>
#import <OCMock/OCMock.h>
#import "RNNotificationEventHandler.h"
#import "RNNotificationUtils.h"
@interface
RNNotificationEventHandlerTests
:
XCTestCase
@property
(
nonatomic
,
retain
)
RNNotificationEventHandler
*
uut
;
@property
(
nonatomic
,
retain
)
RNNotificationsStore
*
store
;
@property
(
nonatomic
,
retain
)
id
mockedNotificationCenter
;
@end
@implementation
RNNotificationEventHandlerTests
-
(
void
)
setUp
{
_store
=
[
RNNotificationsStore
sharedInstance
];
_uut
=
[[
RNNotificationEventHandler
alloc
]
initWithStore
:
_store
];
_mockedNotificationCenter
=
[
OCMockObject
partialMockForObject
:[
NSNotificationCenter
new
]];
[[[[[
OCMockObject
niceMockForClass
:
NSNotificationCenter
.
class
]
stub
]
classMethod
]
andReturn
:
_mockedNotificationCenter
]
defaultCenter
];
}
-
(
void
)
testDidRegisterForRemoteNotifications_ShouldEmitEventWithDeviceTokenDataString
{
NSData
*
deviceToken
=
[
@"740f4707 bebcf74f 9b7c25d4 8e335894 5f6aa01d a5ddb387 462c7eaf 61bb78ad"
dataUsingEncoding
:
NSUTF32StringEncoding
];
[[
_mockedNotificationCenter
expect
]
postNotificationName
:
RNRegistered
object
:[
OCMArg
any
]
userInfo
:
[
OCMArg
checkWithBlock
:
^
BOOL
(
id
obj
)
{
return
([[
obj
objectForKey
:
@"deviceToken"
]
isEqualToString
:[
RNNotificationUtils
deviceTokenToString
:
deviceToken
]]);
}]];
[
_uut
didRegisterForRemoteNotificationsWithDeviceToken
:
deviceToken
];
[
_mockedNotificationCenter
verify
];
}
-
(
void
)
testDidRegisterForRemoteNotifications_ShouldEmitEventWithDeviceTokenString
{
NSString
*
deviceToken
=
@"740f4707 bebcf74f 9b7c25d4 8e335894 5f6aa01d a5ddb387 462c7eaf 61bb78ad"
;
[[
_mockedNotificationCenter
expect
]
postNotificationName
:
RNRegistered
object
:[
OCMArg
any
]
userInfo
:
[
OCMArg
checkWithBlock
:
^
BOOL
(
id
obj
)
{
return
([[
obj
objectForKey
:
@"deviceToken"
]
isEqualToString
:
deviceToken
]);
}]];
[
_uut
didRegisterForRemoteNotificationsWithDeviceToken
:
deviceToken
];
[
_mockedNotificationCenter
verify
];
}
-
(
void
)
testDidFailToRegisterForRemoteNotifications_ShouldEmitEvent
{
NSError
*
error
=
[
NSError
errorWithDomain
:
@"domain"
code
:
1
userInfo
:
nil
];
[[
_mockedNotificationCenter
expect
]
postNotificationName
:
RNRegistrationFailed
object
:[
OCMArg
any
]
userInfo
:
[
OCMArg
checkWithBlock
:
^
BOOL
(
id
obj
)
{
return
([[
obj
valueForKey
:
@"code"
]
isEqualToNumber
:
@
(
1
)]
&&
[[
obj
valueForKey
:
@"domain"
]
isEqualToString
:
@"domain"
]);
}]];
[
_uut
didFailToRegisterForRemoteNotificationsWithError
:
error
];
[
_mockedNotificationCenter
verify
];
}
@end
RNNotifications/RNNotificationsTests/RNNotificationsStoreTests.m
0 → 100644
View file @
4908c56e
#import <XCTest/XCTest.h>
#import <OCMock/OCMock.h>
#import "RNNotificationsStore.h"
@interface
RNNotificationsStoreTests
:
XCTestCase
@property
(
nonatomic
,
retain
)
RNNotificationsStore
*
store
;
@end
@implementation
RNNotificationsStoreTests
-
(
void
)
setUp
{
_store
=
[
RNNotificationsStore
sharedInstance
];
}
-
(
void
)
testSetActionCompletionHandler_ShouldStoreBlock
{
void
(
^
testBlock
)(
void
)
=
^
void
()
{};
[
_store
setActionCompletionHandler
:
testBlock
withCompletionKey
:
@"actionTestBlock"
];
XCTAssertEqual
(
testBlock
,
[
_store
getActionCompletionHandler
:
@"actionTestBlock"
]);
}
-
(
void
)
testCompleteAction_ShouldInvokeBlock
{
__block
BOOL
blockInvoked
=
NO
;
void
(
^
testBlock
)(
void
)
=
^
void
()
{
blockInvoked
=
YES
;
};
[
_store
setActionCompletionHandler
:
testBlock
withCompletionKey
:
@"actionTestBlock"
];
[
_store
completeAction
:
@"actionTestBlock"
];
XCTAssertTrue
(
blockInvoked
);
}
-
(
void
)
testCompleteAction_ShouldRemoveBlock
{
__block
BOOL
blockInvoked
=
NO
;
void
(
^
testBlock
)(
void
)
=
^
void
()
{
blockInvoked
=
YES
;
};
[
_store
setActionCompletionHandler
:
testBlock
withCompletionKey
:
@"actionTestBlock"
];
[
_store
completeAction
:
@"actionTestBlock"
];
XCTAssertNil
([
_store
getActionCompletionHandler
:
@"actionTestBlock"
]);
}
-
(
void
)
testSetPersentationCompletionHandler_ShouldStoreBlock
{
void
(
^
testBlock
)(
UNNotificationPresentationOptions
)
=
^
void
(
UNNotificationPresentationOptions
options
)
{};
[
_store
setPresentationCompletionHandler
:
testBlock
withCompletionKey
:
@"presentationTestBlock"
];
XCTAssertEqual
(
testBlock
,
[
_store
getPresentationCompletionHandler
:
@"presentationTestBlock"
]);
}
-
(
void
)
testCompletePresentation_ShouldInvokeBlockWithParams
{
__block
UNNotificationPresentationOptions
presentationOptions
;
void
(
^
testBlock
)(
UNNotificationPresentationOptions
)
=
^
void
(
UNNotificationPresentationOptions
options
)
{
presentationOptions
=
options
;
};
[
_store
setPresentationCompletionHandler
:
testBlock
withCompletionKey
:
@"presentationTestBlock"
];
[
_store
completePresentation
:
@"presentationTestBlock"
withPresentationOptions
:
UNNotificationPresentationOptionAlert
];
XCTAssertEqual
(
presentationOptions
,
UNNotificationPresentationOptionAlert
);
}
-
(
void
)
testCompletePresentation_ShouldRemoveBlock
{
__block
UNNotificationPresentationOptions
presentationOptions
;
void
(
^
testBlock
)(
UNNotificationPresentationOptions
)
=
^
void
(
UNNotificationPresentationOptions
options
)
{
presentationOptions
=
options
;
};
[
_store
setPresentationCompletionHandler
:
testBlock
withCompletionKey
:
@"presentationTestBlock"
];
[
_store
completePresentation
:
@"presentationTestBlock"
withPresentationOptions
:
UNNotificationPresentationOptionAlert
];
XCTAssertNil
([
_store
getPresentationCompletionHandler
:
@"presentationTestBlock"
]);
}
@end
RNNotifications/libOCMock.a
0 → 100644
View file @
4908c56e
File added
example/ios/NotificationsExampleApp.xcodeproj/xcshareddata/xcschemes/NotificationsExampleApp.xcscheme
View file @
4908c56e
...
...
@@ -34,20 +34,6 @@
ReferencedContainer =
"container:../../node_modules/react-native/React/React.xcodeproj"
>
</BuildableReference>
</BuildActionEntry>
<BuildActionEntry
buildForTesting =
"YES"
buildForRunning =
"YES"
buildForProfiling =
"YES"
buildForArchiving =
"YES"
buildForAnalyzing =
"YES"
>
<BuildableReference
BuildableIdentifier =
"primary"
BlueprintIdentifier =
"58B511DA1A9E6C8500147676"
BuildableName =
"libRNNotifications.a"
BlueprintName =
"RNNotifications"
ReferencedContainer =
"container:../../RNNotifications/RNNotifications.xcodeproj"
>
</BuildableReference>
</BuildActionEntry>
<BuildActionEntry
buildForTesting =
"YES"
buildForRunning =
"YES"
...
...
@@ -68,8 +54,36 @@
buildConfiguration =
"Debug"
selectedDebuggerIdentifier =
"Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier =
"Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv =
"YES"
>
codeCoverageEnabled =
"YES"
onlyGenerateCoverageForSpecifiedTargets =
"YES"
shouldUseLaunchSchemeArgsEnv =
"NO"
>
<CodeCoverageTargets>
<BuildableReference
BuildableIdentifier =
"primary"
BlueprintIdentifier =
"13B07F861A680F5B00A75B9A"
BuildableName =
"NotificationsExampleApp.app"
BlueprintName =
"NotificationsExampleApp"
ReferencedContainer =
"container:NotificationsExampleApp.xcodeproj"
>
</BuildableReference>
<BuildableReference
BuildableIdentifier =
"primary"
BlueprintIdentifier =
"508CE7C722D12B2600357815"
BuildableName =
"RNNotificationsTests.xctest"
BlueprintName =
"RNNotificationsTests"
ReferencedContainer =
"container:../../RNNotifications/RNNotifications.xcodeproj"
>
</BuildableReference>
</CodeCoverageTargets>
<Testables>
<TestableReference
skipped =
"NO"
>
<BuildableReference
BuildableIdentifier =
"primary"
BlueprintIdentifier =
"508CE7C722D12B2600357815"
BuildableName =
"RNNotificationsTests.xctest"
BlueprintName =
"RNNotificationsTests"
ReferencedContainer =
"container:../../RNNotifications/RNNotifications.xcodeproj"
>
</BuildableReference>
</TestableReference>
</Testables>
<MacroExpansion>
<BuildableReference
...
...
@@ -80,6 +94,13 @@
ReferencedContainer =
"container:NotificationsExampleApp.xcodeproj"
>
</BuildableReference>
</MacroExpansion>
<EnvironmentVariables>
<EnvironmentVariable
key =
"TEST_ENABLED"
value =
"YES"
isEnabled =
"YES"
>
</EnvironmentVariable>
</EnvironmentVariables>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
...
...
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