Skip to content

Commit

Permalink
initWithContext synchronization fix (#1903)
Browse files Browse the repository at this point in the history
  • Loading branch information
brismithers authored and jinliu9508 committed Jan 31, 2024
1 parent 1835b83 commit 68a4d42
Showing 1 changed file with 44 additions and 0 deletions.
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'"
}
})

0 comments on commit 68a4d42

Please sign in to comment.