11import fetch from 'jest-fetch-mock' ;
22import checkVersion from '../src' ;
3+ import checkIOS from '../src/ios' ;
4+ import checkAndroid from '../src/android' ;
35
46describe ( 'checkVersion' , ( ) => {
57 beforeEach ( ( ) => {
6- jest . mock ( 'Platform' , ( ) => ( {
7- OS : 'android' ,
8- } ) ) ;
8+ jest . mock ( 'Platform' , ( ) => ( { OS : 'android' } ) ) ;
99 jest . mock ( 'fetch' , fetch ) ;
10+ jest . setTimeout ( 30000 ) ;
1011 } ) ;
1112
1213 it ( 'error pattern' , async ( ) => {
@@ -19,18 +20,42 @@ describe('checkVersion', () => {
1920 expect ( result ) . toHaveProperty ( 'error' , true ) ;
2021 } ) ;
2122
22- it ( 'correct pattern' , async ( ) => {
23- const result = await checkVersion ( {
24- version : '1.0.0' ,
25- iosStoreURL : 'https://itunes.apple.com/app/id1321198947?mt=8' ,
26- androidStoreURL : 'https://play.google.com/store/apps/details?id=jp.ewaf.pinpoint.android' ,
27- } ) ;
23+ it ( 'ios correct pattern 1' , async ( ) => {
24+ const result = await checkIOS (
25+ '1.0.0' ,
26+ 'https://itunes.apple.com/app/id1321198947?mt=8' ,
27+ ) ;
28+
29+ console . log ( result ) ;
30+
31+ expect ( result ) . toHaveProperty ( 'local' ) ;
32+ expect ( result ) . toHaveProperty ( 'remote' ) ;
33+ expect ( result ) . toHaveProperty ( 'result' , 'new' ) ;
34+ } ) ;
35+
36+ it ( 'ios correct pattern 2' , async ( ) => {
37+ const result = await checkIOS (
38+ '1.0.0' ,
39+ 'https://itunes.apple.com/jp/app/pin-point/id1321198947' ,
40+ ) ;
41+
42+ console . log ( result ) ;
43+
44+ expect ( result ) . toHaveProperty ( 'local' ) ;
45+ expect ( result ) . toHaveProperty ( 'remote' ) ;
46+ expect ( result ) . toHaveProperty ( 'result' , 'new' ) ;
47+ } ) ;
48+
49+ it ( 'android correct pattern' , async ( ) => {
50+ const result = await checkAndroid (
51+ '10.0.0' ,
52+ 'https://play.google.com/store/apps/details?id=jp.ewaf.likedsearch.android' ,
53+ ) ;
2854
2955 console . log ( result ) ;
3056
31- expect ( result ) . toHaveProperty ( 'error' , false ) ;
3257 expect ( result ) . toHaveProperty ( 'local' ) ;
3358 expect ( result ) . toHaveProperty ( 'remote' ) ;
34- expect ( result ) . toHaveProperty ( 'result' ) ;
59+ expect ( result ) . toHaveProperty ( 'result' , 'old' ) ;
3560 } ) ;
3661} ) ;
0 commit comments