Created SaleTaxTests test suite
This commit is contained in:
parent
b05caa7245
commit
6be3ba0702
|
@ -0,0 +1,38 @@
|
|||
import Vapor
|
||||
import XCTest
|
||||
@testable import TaxJar
|
||||
|
||||
final class SaleTaxTests: XCTestCase {
|
||||
var app: Application!
|
||||
|
||||
override func setUp() {
|
||||
super.setUp()
|
||||
|
||||
guard let key = Environment.get("TAXJAR_KEY") else {
|
||||
fatalError("Please create an environment variable `TAXJAR_KEY` with you TaxJar API key.")
|
||||
}
|
||||
var services = Services.default()
|
||||
try! services.register(TaxJarProvider(key: key))
|
||||
|
||||
self.app = try! Application.testable(services: services)
|
||||
}
|
||||
|
||||
func testTax()throws {
|
||||
let from = Address(country: .unitedStates, zip: "92093", state: .ca, city: "La Jolla", street: "9500 Gilman Drive")
|
||||
let to = Address(country: .unitedStates, zip: "90002", state: .ca, city: "Los Angeles", street: "1335 E 103rd St")
|
||||
let nexus = [Address(id: "Main Location", country: .unitedStates, zip: "92093", state: .ca, city: "La Jolla", street: "9500 Gilman Drive")]
|
||||
let items = [LineItem(id: "1", quantity: 1, taxCode: "20010", price: 15, discount: 0)]
|
||||
let request = Tax.CalculateRequest(from: from, to: to, amount: 15, shipping: 1.5, customer: "31415", nexus: nexus, items: items)
|
||||
|
||||
let tax = try self.app.make(SalesTax.self).tax(for: request).wait()
|
||||
|
||||
print(tax)
|
||||
}
|
||||
|
||||
static var allTests: [(String, (SaleTaxTests) -> ()throws -> ())] = [
|
||||
("testTax", testTax)
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -3,6 +3,8 @@ import XCTest
|
|||
#if !os(macOS)
|
||||
public func allTests() -> [XCTestCaseEntry] {
|
||||
return [
|
||||
|
||||
// MARK: - Models
|
||||
testCase(TaxJarTests.allTests),
|
||||
testCase(EnvironmentTests.allTests),
|
||||
testCase(AddressTests.allTests),
|
||||
|
@ -11,6 +13,9 @@ public func allTests() -> [XCTestCaseEntry] {
|
|||
testCase(JurisdictionsTests.allCases),
|
||||
testCase(BreakdownTests.allCases),
|
||||
testCase(TaxTests.allCases),
|
||||
|
||||
// MARK: - Controllers
|
||||
testCase(SaleTaxTests.allCases)
|
||||
]
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue