Signal-iOS/SignalServiceKit/tests/Network/OWSRequestFactoryTest.swift
Evan Hahn f4714b1a83 Basic support for sending gift badges
If you've got the `giftBadgeSending` flag enabled, you can now send gift
badges to anyone who has the capability.

This commit doesn't complete the feature, though. It is missing:

- Proper durability and error handling (to be addressed separately)
- Saving of receipts
- A few other cleanups
2022-06-22 15:50:51 +00:00

29 lines
1.1 KiB
Swift

//
// Copyright (c) 2022 Open Whisper Systems. All rights reserved.
//
import XCTest
import SignalServiceKit
class OWSRequestFactoryTest: XCTestCase {
func testBoostCreatePaymentIntentWithAmount() {
let request = OWSRequestFactory.boostCreatePaymentIntent(withAmount: 123, inCurrencyCode: "CHF", level: 456)
XCTAssertEqual(request.url?.path, "v1/subscription/boost/create")
XCTAssertEqual(request.httpMethod, "POST")
XCTAssertEqual(Set(request.parameters.keys), Set(["currency", "amount", "level"]))
XCTAssertEqual(request.parameters["currency"] as? String, "chf")
XCTAssertEqual(request.parameters["amount"] as? UInt, 123)
XCTAssertEqual(request.parameters["level"] as? UInt64, 456)
XCTAssertFalse(request.shouldHaveAuthorizationHeaders)
}
func testGiftBadgePricesRequest() throws {
let request = OWSRequestFactory.giftBadgePricesRequest()
XCTAssertEqual(request.url?.path, "v1/subscription/boost/amounts/gift")
XCTAssertEqual(request.httpMethod, "GET")
XCTAssertTrue(request.parameters.isEmpty)
}
}