Skip to content

Commit

Permalink
Merge pull request #7 from watanabeyu/develop
Browse files Browse the repository at this point in the history
fix iOS url bug.
  • Loading branch information
watanabeyu authored May 9, 2019
2 parents 00fafb5 + a81d890 commit b1e4657
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 13 deletions.
47 changes: 36 additions & 11 deletions __tests__/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import fetch from 'jest-fetch-mock';
import checkVersion from '../src';
import checkIOS from '../src/ios';
import checkAndroid from '../src/android';

describe('checkVersion', () => {
beforeEach(() => {
jest.mock('Platform', () => ({
OS: 'android',
}));
jest.mock('Platform', () => ({ OS: 'android' }));
jest.mock('fetch', fetch);
jest.setTimeout(30000);
});

it('error pattern', async () => {
Expand All @@ -19,18 +20,42 @@ describe('checkVersion', () => {
expect(result).toHaveProperty('error', true);
});

it('correct pattern', async () => {
const result = await checkVersion({
version: '1.0.0',
iosStoreURL: 'https://itunes.apple.com/app/id1321198947?mt=8',
androidStoreURL: 'https://play.google.com/store/apps/details?id=jp.ewaf.pinpoint.android',
});
it('ios correct pattern 1', async () => {
const result = await checkIOS(
'1.0.0',
'https://itunes.apple.com/app/id1321198947?mt=8',
);

console.log(result);

expect(result).toHaveProperty('local');
expect(result).toHaveProperty('remote');
expect(result).toHaveProperty('result', 'new');
});

it('ios correct pattern 2', async () => {
const result = await checkIOS(
'1.0.0',
'https://itunes.apple.com/jp/app/pin-point/id1321198947',
);

console.log(result);

expect(result).toHaveProperty('local');
expect(result).toHaveProperty('remote');
expect(result).toHaveProperty('result', 'new');
});

it('android correct pattern', async () => {
const result = await checkAndroid(
'10.0.0',
'https://play.google.com/store/apps/details?id=jp.ewaf.likedsearch.android',
);

console.log(result);

expect(result).toHaveProperty('error', false);
expect(result).toHaveProperty('local');
expect(result).toHaveProperty('remote');
expect(result).toHaveProperty('result');
expect(result).toHaveProperty('result', 'old');
});
});
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-native-store-version",
"version": "1.1.4",
"version": "1.1.5",
"main": "dist/index.js",
"types": "index.d.ts",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion src/ios.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const checkIOS: checkPlatform = async (version: string, storeURL: string) => {
const appID = storeURL.match(/.+id([0-9]+)\?/);
const appID = storeURL.match(/.+id([0-9]+)\??/);

if (!appID) {
throw new Error('iosStoreURL is invalid.');
Expand Down

0 comments on commit b1e4657

Please sign in to comment.