-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[expo-updates] Gate roll back to embedded to expo-updates >= 0.19.0 (#…
- Loading branch information
Showing
6 changed files
with
97 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
packages/eas-cli/src/project/__tests__/projectUtils.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import { AppJSONConfig, PackageJSONConfig } from '@expo/config'; | ||
import { vol } from 'memfs'; | ||
import path from 'path'; | ||
import resolveFrom from 'resolve-from'; | ||
|
||
import { enforceRollBackToEmbeddedUpdateSupportAsync } from '../projectUtils'; | ||
|
||
jest.mock('fs'); | ||
jest.mock('resolve-from'); | ||
|
||
const projectRoot = '/test-project'; | ||
|
||
describe(enforceRollBackToEmbeddedUpdateSupportAsync, () => { | ||
it('does not throw when an appropriate version is installed', async () => { | ||
mockTestProject('0.19.1'); | ||
|
||
await enforceRollBackToEmbeddedUpdateSupportAsync(projectRoot); | ||
}); | ||
|
||
it('throws when an unappropriate version is installed', async () => { | ||
mockTestProject('0.18.0'); | ||
|
||
await expect(enforceRollBackToEmbeddedUpdateSupportAsync(projectRoot)).rejects.toThrowError( | ||
'The expo-updates package must have a version >= 0.19.0 to use roll back to embedded, which corresponds to Expo SDK 50 or greater.' | ||
); | ||
}); | ||
}); | ||
|
||
function mockTestProject(expoUpdatesPackageVersion: string): { appJson: AppJSONConfig } { | ||
const packageJSON: PackageJSONConfig = { | ||
name: 'testing123', | ||
version: '0.1.0', | ||
description: 'fake description', | ||
main: 'index.js', | ||
dependencies: { | ||
'expo-updates': expoUpdatesPackageVersion, | ||
}, | ||
}; | ||
|
||
const expoUpdatesPackageJSON: PackageJSONConfig = { | ||
name: 'expo-updates', | ||
version: expoUpdatesPackageVersion, | ||
}; | ||
|
||
const appJSON: AppJSONConfig = { | ||
expo: { | ||
name: 'testing 123', | ||
version: '0.1.0', | ||
slug: 'testing-123', | ||
sdkVersion: '33.0.0', | ||
}, | ||
}; | ||
|
||
jest | ||
.mocked(resolveFrom.silent) | ||
.mockReturnValue(path.join(projectRoot, 'node_modules/expo-updates/package.json')); | ||
|
||
vol.fromJSON( | ||
{ | ||
'package.json': JSON.stringify(packageJSON), | ||
'app.json': JSON.stringify(appJSON), | ||
'node_modules/expo-updates/package.json': JSON.stringify(expoUpdatesPackageJSON), | ||
}, | ||
projectRoot | ||
); | ||
|
||
return { appJson: appJSON }; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters