@@ -37,13 +37,36 @@ class TransloaditKitTests: XCTestCase {
3737
3838 let configuration = URLSessionConfiguration . default
3939 configuration. protocolClasses = [ MockURLProtocol . self]
40- let session = URLSession . init ( configuration: configuration)
4140
42- return Transloadit ( credentials: credentials, session: session)
41+ return Transloadit ( credentials: credentials, sessionConfiguration: configuration)
42+ }
43+
44+ func testCreateAssembly_Calls_Injected_Signature_Generator( ) throws {
45+ let configuration = URLSessionConfiguration . default
46+ configuration. protocolClasses = [ MockURLProtocol . self]
47+
48+ let signatureExpectation = expectation ( description: " Waiting for signature to be requested " )
49+ let client = Transloadit ( apiKey: " I am a key " , sessionConfiguration: configuration, signatureGenerator: { params, completion in
50+ signatureExpectation. fulfill ( )
51+ completion ( . success( " signed: " + params) )
52+ } )
53+
54+ let serverAssembly = Fixtures . makeAssembly ( )
55+ Network . prepareAssemblyResponse ( assembly: serverAssembly)
56+ let serverFinishedExpectation = expectation ( description: " Waiting for createAssembly to be called " )
57+ client. createAssembly ( steps: [ resizeStep] ) { result in
58+ switch result {
59+ case . success:
60+ serverFinishedExpectation. fulfill ( )
61+ case . failure:
62+ XCTFail ( " Creating an assembly should have succeeded " )
63+ }
64+ }
65+
66+ waitForExpectations ( timeout: 3.0 , handler: nil )
4367 }
4468
4569 // MARK: - File uploading
46-
4770 func testCreateAssembly_Without_Uploading( ) throws {
4871 let serverAssembly = Fixtures . makeAssembly ( )
4972 Network . prepareAssemblyResponse ( assembly: serverAssembly)
0 commit comments