@@ -2,17 +2,19 @@ import {
2
2
Platform ,
3
3
getAmplifyUserAgent ,
4
4
getAmplifyUserAgentObject ,
5
+ sanitizeAmplifyVersion ,
5
6
} from '../../src/Platform' ;
6
- import { version } from '../../src/Platform/version' ;
7
7
import { AuthAction , Category , Framework } from '../../src/Platform/types' ;
8
8
import {
9
9
clearCache ,
10
10
detectFramework ,
11
11
} from '../../src/Platform/detectFramework' ;
12
12
import * as detection from '../../src/Platform/detection' ;
13
13
import { getCustomUserAgent } from '../../src/Platform/customUserAgent' ;
14
+ import { version } from '../../src/Platform/version' ;
14
15
15
16
jest . mock ( '../../src/Platform/customUserAgent' ) ;
17
+ const expectedVersion = version . replace ( / \+ .* / , '' ) ;
16
18
17
19
describe ( 'Platform test' , ( ) => {
18
20
const mockGetCustomUserAgent = getCustomUserAgent as jest . Mock ;
@@ -36,10 +38,29 @@ describe('Platform test', () => {
36
38
} ) ;
37
39
} ) ;
38
40
41
+ describe ( 'sanitizeAmplifyVersion' , ( ) => {
42
+ test ( 'happy case with no special char' , ( ) => {
43
+ expect ( sanitizeAmplifyVersion ( '6.6.0' ) ) . toEqual ( '6.6.0' ) ;
44
+ } ) ;
45
+
46
+ test ( 'happy case with no special char +' , ( ) => {
47
+ expect (
48
+ sanitizeAmplifyVersion ( '6.6.4-unstable.ffa8a24.0+ffa8a24' ) ,
49
+ ) . toEqual ( '6.6.4-unstable.ffa8a24.0' ) ;
50
+ } ) ;
51
+ } ) ;
52
+
39
53
describe ( 'getAmplifyUserAgentObject test' , ( ) => {
40
54
test ( 'without customUserAgentDetails' , ( ) => {
41
55
expect ( getAmplifyUserAgentObject ( ) ) . toStrictEqual ( [
42
- [ 'aws-amplify' , version ] ,
56
+ [ 'aws-amplify' , expectedVersion ] ,
57
+ [ 'framework' , Framework . WebUnknown ] ,
58
+ ] ) ;
59
+ } ) ;
60
+
61
+ test ( 'should remove value after special char + in version' , ( ) => {
62
+ expect ( getAmplifyUserAgentObject ( ) ) . toStrictEqual ( [
63
+ [ 'aws-amplify' , expectedVersion ] ,
43
64
[ 'framework' , Framework . WebUnknown ] ,
44
65
] ) ;
45
66
} ) ;
@@ -51,7 +72,7 @@ describe('Platform test', () => {
51
72
action : AuthAction . ConfirmSignIn ,
52
73
} ) ,
53
74
) . toStrictEqual ( [
54
- [ 'aws-amplify' , version ] ,
75
+ [ 'aws-amplify' , expectedVersion ] ,
55
76
[ Category . Auth , AuthAction . ConfirmSignIn ] ,
56
77
[ 'framework' , Framework . WebUnknown ] ,
57
78
] ) ;
@@ -68,7 +89,7 @@ describe('Platform test', () => {
68
89
action : AuthAction . ConfirmSignIn ,
69
90
} ) ,
70
91
) . toStrictEqual ( [
71
- [ 'aws-amplify' , version ] ,
92
+ [ 'aws-amplify' , expectedVersion ] ,
72
93
[ Category . Auth , AuthAction . ConfirmSignIn ] ,
73
94
[ 'framework' , Framework . WebUnknown ] ,
74
95
[ 'uiversion' , '1.0.0' ] ,
@@ -124,7 +145,7 @@ describe('Platform test', () => {
124
145
} ) ;
125
146
126
147
describe ( 'detectFramework observers' , ( ) => {
127
- let module ;
148
+ let module : any ;
128
149
129
150
beforeAll ( ( ) => {
130
151
jest . resetModules ( ) ;
0 commit comments