-
Notifications
You must be signed in to change notification settings - Fork 368
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
initWithContext synchronization fix (#1903)
- Loading branch information
1 parent
79c2ac9
commit 11b402d
Showing
2 changed files
with
177 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
OneSignalSDK/onesignal/core/src/test/java/com/onesignal/internal/OneSignalImpTests.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package com.onesignal.internal | ||
|
||
import com.onesignal.debug.LogLevel | ||
import com.onesignal.debug.internal.logging.Logging | ||
import io.kotest.assertions.throwables.shouldThrowUnit | ||
import io.kotest.core.spec.style.FunSpec | ||
import io.kotest.matchers.shouldBe | ||
import io.kotest.runner.junit4.KotestTestRunner | ||
import org.junit.runner.RunWith | ||
|
||
@RunWith(KotestTestRunner::class) | ||
class OneSignalImpTests : FunSpec({ | ||
beforeAny { | ||
Logging.logLevel = LogLevel.NONE | ||
} | ||
|
||
test("attempting login before initWithContext throws exception") { | ||
// Given | ||
val os = OneSignalImp() | ||
|
||
// When | ||
val exception = | ||
shouldThrowUnit<Exception> { | ||
os.login("login-id") | ||
} | ||
|
||
// Then | ||
exception.message shouldBe "Must call 'initWithContext' before 'login'" | ||
} | ||
|
||
test("attempting logout before initWithContext throws exception") { | ||
// Given | ||
val os = OneSignalImp() | ||
|
||
// When | ||
val exception = | ||
shouldThrowUnit<Exception> { | ||
os.logout() | ||
} | ||
|
||
// Then | ||
exception.message shouldBe "Must call 'initWithContext' before 'logout'" | ||
} | ||
}) |