2018-11-11 18:09:52 +01:00
|
|
|
//
|
|
|
|
|
// ConstantsTest.swift
|
|
|
|
|
// passKitTests
|
|
|
|
|
//
|
|
|
|
|
// Created by Danny Moesch on 30.09.18.
|
|
|
|
|
// Copyright © 2018 Bob Sun. All rights reserved.
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
import XCTest
|
|
|
|
|
|
|
|
|
|
@testable import passKit
|
|
|
|
|
|
|
|
|
|
class ConstantsTest: XCTestCase {
|
|
|
|
|
func testIsOtpRelated() {
|
2018-12-15 21:51:22 +01:00
|
|
|
XCTAssert(Constants.isOtpRelated(line: "otpauth://something"))
|
|
|
|
|
XCTAssert(Constants.isOtpRelated(line: "otp_algorithm: algorithm"))
|
2018-11-11 18:09:52 +01:00
|
|
|
XCTAssertFalse(Constants.isOtpRelated(line: "otp: something"))
|
|
|
|
|
XCTAssertFalse(Constants.isOtpRelated(line: "otp"))
|
|
|
|
|
}
|
|
|
|
|
|
2018-12-08 00:56:22 +01:00
|
|
|
func testIsOtpKeyword() {
|
2018-12-15 21:51:22 +01:00
|
|
|
XCTAssert(Constants.isOtpKeyword("otpauth"))
|
|
|
|
|
XCTAssert(Constants.isOtpKeyword("oTP_DigITS"))
|
2018-12-08 00:56:22 +01:00
|
|
|
XCTAssertFalse(Constants.isOtpKeyword("otp"))
|
|
|
|
|
XCTAssertFalse(Constants.isOtpKeyword("no keyword"))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func testIsUnknown() {
|
2019-01-26 16:26:53 +01:00
|
|
|
XCTAssert(Constants.isUnknown("unknown 1"))
|
|
|
|
|
XCTAssert(Constants.isUnknown("unknown 435"))
|
2018-12-08 00:56:22 +01:00
|
|
|
XCTAssertFalse(Constants.isUnknown("otp"))
|
2019-01-26 16:26:53 +01:00
|
|
|
XCTAssertFalse(Constants.isUnknown("unknown "))
|
|
|
|
|
XCTAssertFalse(Constants.isUnknown("unknown something"))
|
|
|
|
|
XCTAssertFalse(Constants.isUnknown("unknown 123 something"))
|
|
|
|
|
XCTAssertFalse(Constants.isUnknown("Unknown 1"))
|
2018-12-08 00:56:22 +01:00
|
|
|
}
|
|
|
|
|
|
2018-11-11 18:09:52 +01:00
|
|
|
func testUnknown() {
|
|
|
|
|
XCTAssertEqual(Constants.unknown(0), "unknown 0")
|
|
|
|
|
XCTAssertEqual(Constants.unknown(10), "unknown 10")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func testGetSeparator() {
|
|
|
|
|
XCTAssertEqual(Constants.getSeparator(breakingLines: true), "\n")
|
|
|
|
|
XCTAssertEqual(Constants.getSeparator(breakingLines: false), " ")
|
|
|
|
|
}
|
|
|
|
|
}
|