Skip to content

Commit

Permalink
Merge pull request #2 from codykerns/fix-tests
Browse files Browse the repository at this point in the history
Fix tests
  • Loading branch information
codykerns authored Feb 22, 2024
2 parents 1421d4f + adb8412 commit 2d91254
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Sources/StableID/StableID.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import Foundation

public class StableID {
private static var _stableID: StableID? = nil
internal static var _stableID: StableID? = nil

private static var shared: StableID {
guard let _stableID else {
Expand Down
20 changes: 12 additions & 8 deletions Tests/StableIDTests/StableIDTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,32 @@ final class StableIDTests: XCTestCase {

func clearDefaults() {
guard let defaults = UserDefaults(suiteName: Constants.StableID_Key_DefaultsSuiteName) else { return }

let dictionary = defaults.dictionaryRepresentation()
dictionary.keys.forEach { key in
print(key)
defaults.removeObject(forKey: key)
}
}

func testConfiguring() {
override func setUp() {
super.setUp()

clearDefaults()
}

override func tearDown() {
super.tearDown()

StableID._stableID = nil
}

func testConfiguring() {
StableID.configure()
XCTAssert(StableID.isConfigured == true)
}

func testIdentifying() {
clearDefaults()

StableID.configure()

let uuid = UUID().uuidString
Expand All @@ -39,8 +47,6 @@ final class StableIDTests: XCTestCase {
}

func testGenerateNewID() {
clearDefaults()

StableID.configure()
let originalID = StableID.id

Expand All @@ -51,8 +57,6 @@ final class StableIDTests: XCTestCase {
}

func testShortIDLength() {
clearDefaults()

StableID.configure(idGenerator: StableID.ShortIDGenerator())

XCTAssert(StableID.id.count == 8)
Expand Down

0 comments on commit 2d91254

Please sign in to comment.