@@ -40,7 +40,7 @@ final class OneSignalNotificationsTests: XCTestCase {
40
40
// Put teardown code here. This method is called after the invocation of each test method in the class.
41
41
}
42
42
43
- func testClearBadgesWhenAppEntersForeground( ) throws {
43
+ func testClearBadgesWhenAppEntersForeground( ) throws { // Fails when running alone
44
44
// NotificationManager Start to register lifecycle listener
45
45
OSNotificationsManager . start ( )
46
46
// Set badge count > 0
@@ -53,7 +53,59 @@ final class OneSignalNotificationsTests: XCTestCase {
53
53
XCTAssertEqual ( UIApplication . shared. applicationIconBadgeNumber, 0 )
54
54
}
55
55
56
- func testDontclearBadgesWhenAppBecomesActive( ) throws {
56
+ func testDontclearBadgesWhenAppBecomesActive( ) throws { // Unable to make it fail alone
57
+ // NotificationManager Start to register lifecycle listener
58
+ OSNotificationsManager . start ( )
59
+ // Set badge count > 0
60
+ UIApplication . shared. applicationIconBadgeNumber = 1
61
+ // Then resign active
62
+ OneSignalCoreMocks . resignActive ( )
63
+ // App becomes active the app
64
+ OneSignalCoreMocks . becomeActive ( )
65
+ // Ensure that badge count == 1
66
+ XCTAssertEqual ( UIApplication . shared. applicationIconBadgeNumber, 1 )
67
+ }
68
+
69
+ func testClearBadgesWhenAppEntersForeground1( ) throws {
70
+ // NotificationManager Start to register lifecycle listener
71
+ OSNotificationsManager . start ( )
72
+ // Set badge count > 0
73
+ UIApplication . shared. applicationIconBadgeNumber = 1
74
+ // Then background the app
75
+ OneSignalCoreMocks . backgroundApp ( )
76
+ // Foreground the app
77
+ OneSignalCoreMocks . foregroundApp ( )
78
+ // Ensure that badge count == 0
79
+ XCTAssertEqual ( UIApplication . shared. applicationIconBadgeNumber, 0 )
80
+ }
81
+
82
+ func testDontclearBadgesWhenAppBecomesActive2( ) throws {
83
+ // NotificationManager Start to register lifecycle listener
84
+ OSNotificationsManager . start ( )
85
+ // Set badge count > 0
86
+ UIApplication . shared. applicationIconBadgeNumber = 1
87
+ // Then resign active
88
+ OneSignalCoreMocks . resignActive ( )
89
+ // App becomes active the app
90
+ OneSignalCoreMocks . becomeActive ( )
91
+ // Ensure that badge count == 1
92
+ XCTAssertEqual ( UIApplication . shared. applicationIconBadgeNumber, 1 )
93
+ }
94
+
95
+ func testClearBadgesWhenAppEntersForeground3( ) throws {
96
+ // NotificationManager Start to register lifecycle listener
97
+ OSNotificationsManager . start ( )
98
+ // Set badge count > 0
99
+ UIApplication . shared. applicationIconBadgeNumber = 1
100
+ // Then background the app
101
+ OneSignalCoreMocks . backgroundApp ( )
102
+ // Foreground the app
103
+ OneSignalCoreMocks . foregroundApp ( )
104
+ // Ensure that badge count == 0
105
+ XCTAssertEqual ( UIApplication . shared. applicationIconBadgeNumber, 0 )
106
+ }
107
+
108
+ func testDontclearBadgesWhenAppBecomesActive4( ) throws {
57
109
// NotificationManager Start to register lifecycle listener
58
110
OSNotificationsManager . start ( )
59
111
// Set badge count > 0
0 commit comments