-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: migrated from Quick & Nimble to use XCTest to remove dependency…
… on third party packages (#213)
- Loading branch information
Showing
9 changed files
with
625 additions
and
769 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
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
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
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
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 |
---|---|---|
@@ -1,74 +1,63 @@ | ||
import Security | ||
import Nimble | ||
import Quick | ||
import XCTest | ||
import SimpleKeychain | ||
|
||
class AccessibilitySpec: QuickSpec { | ||
override class func spec() { | ||
describe("raw representable") { | ||
context("from raw value to case") { | ||
it("should map kSecAttrAccessibleWhenUnlocked") { | ||
let sut = Accessibility(rawValue: kSecAttrAccessibleWhenUnlocked) | ||
expect(sut) == Accessibility.whenUnlocked | ||
} | ||
|
||
it("should map kSecAttrAccessibleWhenUnlockedThisDeviceOnly") { | ||
let sut = Accessibility(rawValue: kSecAttrAccessibleWhenUnlockedThisDeviceOnly) | ||
expect(sut) == Accessibility.whenUnlockedThisDeviceOnly | ||
} | ||
|
||
it("should map kSecAttrAccessibleAfterFirstUnlock") { | ||
let sut = Accessibility(rawValue: kSecAttrAccessibleAfterFirstUnlock) | ||
expect(sut) == Accessibility.afterFirstUnlock | ||
} | ||
|
||
it("should map kSecAttrAccessibleAfterFirstUnlockThisDeviceOnly") { | ||
let sut = Accessibility(rawValue: kSecAttrAccessibleAfterFirstUnlockThisDeviceOnly) | ||
expect(sut) == Accessibility.afterFirstUnlockThisDeviceOnly | ||
} | ||
|
||
it("should map kSecAttrAccessibleWhenPasscodeSetThisDeviceOnly") { | ||
let sut = Accessibility(rawValue: kSecAttrAccessibleWhenPasscodeSetThisDeviceOnly) | ||
expect(sut) == Accessibility.whenPasscodeSetThisDeviceOnly | ||
} | ||
|
||
it("should map unknown values") { | ||
let sut = Accessibility(rawValue: "foo" as CFString) | ||
expect(sut) == Accessibility.afterFirstUnlock | ||
} | ||
} | ||
|
||
context("from case to raw value") { | ||
it("should map whenUnlocked") { | ||
let sut = Accessibility.whenUnlocked.rawValue as String | ||
expect(sut) == (kSecAttrAccessibleWhenUnlocked as String) | ||
} | ||
|
||
it("should map whenUnlockedThisDeviceOnly") { | ||
let sut = Accessibility.whenUnlockedThisDeviceOnly.rawValue as String | ||
expect(sut) == (kSecAttrAccessibleWhenUnlockedThisDeviceOnly as String) | ||
} | ||
|
||
it("should map afterFirstUnlock") { | ||
let sut = Accessibility.afterFirstUnlock.rawValue as String | ||
expect(sut) == (kSecAttrAccessibleAfterFirstUnlock as String) | ||
} | ||
|
||
it("should map afterFirstUnlockThisDeviceOnly") { | ||
let sut = Accessibility.afterFirstUnlockThisDeviceOnly.rawValue as String | ||
expect(sut) == (kSecAttrAccessibleAfterFirstUnlockThisDeviceOnly as String) | ||
} | ||
|
||
it("should map whenPasscodeSetThisDeviceOnly") { | ||
let sut = Accessibility.whenPasscodeSetThisDeviceOnly.rawValue as String | ||
expect(sut) == (kSecAttrAccessibleWhenPasscodeSetThisDeviceOnly as String) | ||
} | ||
|
||
it("should map whenPasscodeSetThisDeviceOnly") { | ||
let sut = Accessibility.whenPasscodeSetThisDeviceOnly.rawValue as String | ||
expect(sut) == (kSecAttrAccessibleWhenPasscodeSetThisDeviceOnly as String) | ||
} | ||
} | ||
} | ||
class AccessibilitySpec: XCTestCase { | ||
|
||
// Test from raw value to case | ||
func testKSecAttrAccessibleWhenUnlocked() { | ||
let sut = Accessibility(rawValue: kSecAttrAccessibleWhenUnlocked) | ||
XCTAssertEqual(sut, Accessibility.whenUnlocked) | ||
} | ||
|
||
func testKSecAttrAccessibleWhenUnlockedThisDeviceOnly() { | ||
let sut = Accessibility(rawValue: kSecAttrAccessibleWhenUnlockedThisDeviceOnly) | ||
XCTAssertEqual(sut, Accessibility.whenUnlockedThisDeviceOnly) | ||
} | ||
|
||
func testKSecAttrAccessibleAfterFirstUnlock() { | ||
let sut = Accessibility(rawValue: kSecAttrAccessibleAfterFirstUnlock) | ||
XCTAssertEqual(sut, Accessibility.afterFirstUnlock) | ||
} | ||
|
||
func testKSecAttrAccessibleAfterFirstUnlockThisDeviceOnly() { | ||
let sut = Accessibility(rawValue: kSecAttrAccessibleAfterFirstUnlockThisDeviceOnly) | ||
XCTAssertEqual(sut, Accessibility.afterFirstUnlockThisDeviceOnly) | ||
} | ||
|
||
func testKSecAttrAccessibleWhenPasscodeSetThisDeviceOnly() { | ||
let sut = Accessibility(rawValue: kSecAttrAccessibleWhenPasscodeSetThisDeviceOnly) | ||
XCTAssertEqual(sut, Accessibility.whenPasscodeSetThisDeviceOnly) | ||
} | ||
|
||
func testUnknownValues() { | ||
let sut = Accessibility(rawValue: "foo" as CFString) | ||
XCTAssertEqual(sut, Accessibility.afterFirstUnlock) | ||
} | ||
|
||
// Test from case to raw value | ||
func testWhenUnlocked() { | ||
let sut = Accessibility.whenUnlocked.rawValue as String | ||
XCTAssertEqual(sut, kSecAttrAccessibleWhenUnlocked as String) | ||
} | ||
|
||
func testWhenUnlockedThisDeviceOnly() { | ||
let sut = Accessibility.whenUnlockedThisDeviceOnly.rawValue as String | ||
XCTAssertEqual(sut, kSecAttrAccessibleWhenUnlockedThisDeviceOnly as String) | ||
} | ||
|
||
func testAfterFirstUnlock() { | ||
let sut = Accessibility.afterFirstUnlock.rawValue as String | ||
XCTAssertEqual(sut, kSecAttrAccessibleAfterFirstUnlock as String) | ||
} | ||
|
||
func testAfterFirstUnlockThisDeviceOnly() { | ||
let sut = Accessibility.afterFirstUnlockThisDeviceOnly.rawValue as String | ||
XCTAssertEqual(sut, kSecAttrAccessibleAfterFirstUnlockThisDeviceOnly as String) | ||
} | ||
|
||
func testWhenPasscodeSetThisDeviceOnly() { | ||
let sut = Accessibility.whenPasscodeSetThisDeviceOnly.rawValue as String | ||
XCTAssertEqual(sut, kSecAttrAccessibleWhenPasscodeSetThisDeviceOnly as String) | ||
} | ||
} |
Oops, something went wrong.