Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโ€™ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BIT-273: Rename old unit tests to follow standard #538

Merged
merged 1 commit into from
Mar 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ import XCTest

class ErrorResponseModelTests: BitwardenTestCase {
/// Tests that `singleMessage()` returns the validation error's message.
func testSingleMessage() throws {
func test_singleMessage() throws {
let json = APITestData.createAccountAccountAlreadyExists.data
let decoder = JSONDecoder()
let subject = try decoder.decode(ErrorResponseModel.self, from: json)
XCTAssertEqual(subject.singleMessage(), "Email '[email protected]' is already taken.")
}

/// Tests that `singleMessage()` returns an error message when there are no validation errors.
func testSingleMessageNilValidationErrors() throws {
func test_singleMessage_nilValidationErrors() throws {
let json = APITestData.createAccountNilValidationErrors.data
let decoder = JSONDecoder()
let subject = try decoder.decode(ErrorResponseModel.self, from: json)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class ResponseValidationErrorModelTests: BitwardenTestCase {
// MARK: - Tests

/// Tests that a response is initialized correctly.
func testInit() {
func test_init() {
let subject = ResponseValidationErrorModel(
error: "invalid_input",
errorDescription: "invalid_username",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import XCTest

final class SequenceAsyncTests: BitwardenTestCase {
/// `asyncMap` correctly maps each element.
func testAsyncMapSuccess() async {
func test_asyncMap_success() async {
let input = [1, 2, 3]
let output = await input.asyncMap { number in
await asyncDouble(number)
Expand All @@ -13,7 +13,7 @@ final class SequenceAsyncTests: BitwardenTestCase {
}

/// `asyncMap` correctly propagates errors.
func testAsyncMapWithError() async {
func test_asyncMap_error() async {
let input = [1, 2, 3]
await assertAsyncThrows {
_ = try await input.asyncMap { number in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class AnyCodableTests: BitwardenTestCase {
}

/// `AnyCodable` can be used to encode JSON.
func testEncode() throws {
func test_encode() throws {
let dictionary: [String: AnyCodable] = [
"minComplexity": AnyCodable.null,
"minLength": AnyCodable.int(12),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class URLSessionHTTPClientTests: XCTestCase {
}

/// `send(_:)` performs the request and returns the response for a 200 status request.
func testSendSuccess200() async throws {
func test_send_success200() async throws {
let urlResponse = HTTPURLResponse(
url: URL(string: "https://example.com")!,
statusCode: 200,
Expand All @@ -47,7 +47,7 @@ class URLSessionHTTPClientTests: XCTestCase {
}

/// `send(_:)` performs the request and returns the response for a 500 status request.
func testSendSuccess500() async throws {
func test_send_success500() async throws {
let urlResponse = HTTPURLResponse(
url: URL(string: "https://example.com")!,
statusCode: 500,
Expand All @@ -69,7 +69,7 @@ class URLSessionHTTPClientTests: XCTestCase {
}

/// `send(_:)` performs the request and throws an error if one occurs.
func testSendError() async throws {
func test_send_error() async throws {
URLProtocolMocking.mock(
HTTPRequest.default.url,
with: .failure(NSError(domain: NSURLErrorDomain, code: NSURLErrorTimedOut, userInfo: nil))
Expand Down
6 changes: 3 additions & 3 deletions Networking/Tests/NetworkingTests/HTTPRequestTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class HTTPRequestTests: XCTestCase {
}

/// The initializer provides default values.
func testInitDefaultValues() {
func test_init_defaultValues() {
let subject = HTTPRequest(url: URL(string: "https://example.com")!)

XCTAssertNil(subject.body)
Expand All @@ -23,7 +23,7 @@ class HTTPRequestTests: XCTestCase {
}

/// The initializer sets the item's properties.
func testInit() throws {
func test_init() throws {
let subject = HTTPRequest(
url: URL(string: "https://example.com/json")!,
method: .post,
Expand All @@ -50,7 +50,7 @@ class HTTPRequestTests: XCTestCase {
}

/// `init(request:baseURL)` builds a `HTTPRequest` from a `Request` object.
func testInitRequest() throws {
func test_init_request() throws {
let subject = try HTTPRequest(
request: TestRequest(),
baseURL: URL(string: "https://example.com/")!
Expand Down
6 changes: 3 additions & 3 deletions Networking/Tests/NetworkingTests/HTTPResponseTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import XCTest

class HTTPResponseTests: XCTestCase {
/// The initializer sets the item's properties.
func testInit() {
func test_init() {
let subject = HTTPResponse(
url: URL(string: "https://example.com")!,
statusCode: 200,
Expand All @@ -20,7 +20,7 @@ class HTTPResponseTests: XCTestCase {
}

/// The initializer sets the item's properties with a `HTTPURLResponse`.
func testInitResponse() throws {
func test_init_httpUrlResponse() throws {
let subject = try HTTPResponse(
data: "response body".data(using: .utf8)!,
response: XCTUnwrap(HTTPURLResponse(
Expand All @@ -42,7 +42,7 @@ class HTTPResponseTests: XCTestCase {
}

/// Initializing an `HTTPResponse` with an `URLResponse` vs a `HTTPURLResponse` throws an error.
func testInitWithURLResponseThrowsError() {
func test_init_urlResponse_error() {
let urlResponse = URLResponse(
url: URL(string: "https://example.com")!,
mimeType: nil,
Expand Down
2 changes: 1 addition & 1 deletion Networking/Tests/NetworkingTests/RequestTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class RequestTests: XCTestCase {
}

/// `Request` default.
func testRequest() {
func test_request() {
let request = DefaultRequest()
XCTAssertEqual(request.method, .get)
XCTAssertNil(request.body)
Expand Down
4 changes: 2 additions & 2 deletions Networking/Tests/NetworkingTests/ResponseTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import XCTest

class ResponseTests: XCTestCase {
/// Test creating a `Response` from JSON.
func testJSONResponse() throws {
func test_jsonresponse() throws {
let httpResponse = HTTPResponse(
url: URL(string: "http://example.com")!,
statusCode: 200,
Expand All @@ -17,7 +17,7 @@ class ResponseTests: XCTestCase {
}

/// Test creating a `Response` from a JSON array.
func testJSONArray() throws {
func test_jsonresponse_array() throws {
let httpResponse = HTTPResponse(
url: URL(string: "http://example.com")!,
statusCode: 200,
Expand Down
Loading