Skip to content

Commit b1e4657

Browse files
authored
Merge pull request #7 from watanabeyu/develop
fix iOS url bug.
2 parents 00fafb5 + a81d890 commit b1e4657

3 files changed

Lines changed: 38 additions & 13 deletions

File tree

__tests__/index.test.ts

Lines changed: 36 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
import fetch from 'jest-fetch-mock';
22
import checkVersion from '../src';
3+
import checkIOS from '../src/ios';
4+
import checkAndroid from '../src/android';
35

46
describe('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
});

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-native-store-version",
3-
"version": "1.1.4",
3+
"version": "1.1.5",
44
"main": "dist/index.js",
55
"types": "index.d.ts",
66
"license": "MIT",

src/ios.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const checkIOS: checkPlatform = async (version: string, storeURL: string) => {
2-
const appID = storeURL.match(/.+id([0-9]+)\?/);
2+
const appID = storeURL.match(/.+id([0-9]+)\??/);
33

44
if (!appID) {
55
throw new Error('iosStoreURL is invalid.');

0 commit comments

Comments
 (0)