@@ -10,14 +10,26 @@ import XCTest
10
10
11
11
class AmplifyAWSServiceConfigurationTests : XCTestCase {
12
12
let credentialProvider = AWSAuthService ( ) . getCredentialsProvider ( )
13
+
14
+ override func tearDown( ) {
15
+ AmplifyAWSServiceConfiguration . platformMapping = [ : ]
16
+ }
17
+
18
+ /// Test initiating AmplifyAWSServiceConfiguration
19
+ ///
20
+ /// - Given: Amplify library
21
+ /// - When:
22
+ /// - I call AmplifyAWSServiceConfiguration with credential provider
23
+ /// - Then:
24
+ /// - AmplifyAWSServiceConfiguration should be configured properly
25
+ ///
13
26
func testInstantiation( ) {
14
27
let currentSystemName = UIDevice . current. systemName. replacingOccurrences ( of: " " , with: " - " )
15
28
let currentSystemVersion = UIDevice . current. systemVersion
16
29
let expectedLocale = Locale . current. identifier
17
30
let expectedSystem = " \( currentSystemName) / \( currentSystemVersion) "
18
31
19
- let configuration = AmplifyAWSServiceConfiguration ( region: . USEast1,
20
- credentialsProvider: credentialProvider)
32
+ let configuration = AmplifyAWSServiceConfiguration ( region: . USEast1, credentialsProvider: credentialProvider)
21
33
22
34
XCTAssertNotNil ( configuration. userAgent)
23
35
let userAgentParts = configuration. userAgent. components ( separatedBy: " " )
@@ -26,4 +38,30 @@ class AmplifyAWSServiceConfigurationTests: XCTestCase {
26
38
XCTAssertEqual ( expectedSystem, userAgentParts [ 1 ] )
27
39
XCTAssertEqual ( expectedLocale, userAgentParts [ 2 ] )
28
40
}
41
+
42
+ /// Test adding a new platform to AmplifyAWSServiceConfiguration
43
+ ///
44
+ /// - Given: Amplify library
45
+ /// - When:
46
+ /// - I add a new platform to the AmplifyAWSServiceConfiguration
47
+ /// - Then:
48
+ /// - AmplifyAWSServiceConfiguration should be configured properly with the new platform added.
49
+ ///
50
+ func testAddNewPlatform( ) {
51
+ AmplifyAWSServiceConfiguration . addUserAgentPlatform ( . flutter, version: " 1.1 " )
52
+ let currentSystemName = UIDevice . current. systemName. replacingOccurrences ( of: " " , with: " - " )
53
+ let currentSystemVersion = UIDevice . current. systemVersion
54
+ let expectedLocale = Locale . current. identifier
55
+ let expectedSystem = " \( currentSystemName) / \( currentSystemVersion) "
56
+ let expectedPlatform = " \( AmplifyAWSServiceConfiguration . Platform. flutter. rawValue) /1.1 "
57
+ let configuration = AmplifyAWSServiceConfiguration ( )
58
+
59
+ XCTAssertNotNil ( configuration. userAgent)
60
+ let userAgentParts = configuration. userAgent. components ( separatedBy: " " )
61
+ XCTAssertEqual ( 4 , userAgentParts. count)
62
+ XCTAssertEqual ( expectedPlatform, userAgentParts [ 0 ] )
63
+ XCTAssert ( userAgentParts [ 1 ] . starts ( with: " amplify-iOS/ " ) )
64
+ XCTAssertEqual ( expectedSystem, userAgentParts [ 2 ] )
65
+ XCTAssertEqual ( expectedLocale, userAgentParts [ 3 ] )
66
+ }
29
67
}
0 commit comments