This repository has been archived by the owner on Jan 18, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 478
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add owner field support to expo start (#2329)
Fixes #2242.
- Loading branch information
Showing
3 changed files
with
106 additions
and
27 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import { ExpoConfig } from '@expo/config'; | ||
import axios from 'axios'; | ||
|
||
import { getSignedManifestStringAsync, getUnsignedManifestString } from '../Project'; | ||
|
||
jest.mock('axios'); | ||
|
||
const mockManifest: ExpoConfig = { | ||
name: 'Hello', | ||
slug: 'hello-world', | ||
owner: 'ownername', | ||
version: '1.0.0', | ||
platforms: ['ios'], | ||
}; | ||
|
||
const mockSignedManifestResponse = JSON.stringify({ | ||
manifestString: JSON.stringify(mockManifest), | ||
signature: 'SIGNATURE_HERE', | ||
version: '1.0.0', | ||
}); | ||
|
||
describe('getSignedManifestStringAsync', () => { | ||
it('calls the server API to sign a manifest', async () => { | ||
const requestFunction = axios.request as jest.MockedFunction<typeof axios.request>; | ||
requestFunction.mockReturnValueOnce( | ||
Promise.resolve({ | ||
status: 200, | ||
data: { data: { response: mockSignedManifestResponse } }, | ||
}) | ||
); | ||
const manifestString = await getSignedManifestStringAsync(mockManifest, { | ||
sessionSecret: 'SECRET', | ||
}); | ||
expect(manifestString).toBe(mockSignedManifestResponse); | ||
expect(requestFunction.mock.calls[0][0]).toMatchInlineSnapshot(` | ||
Object { | ||
"data": Object { | ||
"args": Object { | ||
"remotePackageName": "hello-world", | ||
"remoteUsername": "ownername", | ||
}, | ||
"manifest": Object { | ||
"name": "Hello", | ||
"owner": "ownername", | ||
"platforms": Array [ | ||
"ios", | ||
], | ||
"slug": "hello-world", | ||
"version": "1.0.0", | ||
}, | ||
}, | ||
"headers": Object { | ||
"Expo-Session": "SECRET", | ||
"Exponent-Client": "xdl", | ||
}, | ||
"maxContentLength": 104857600, | ||
"method": "post", | ||
"url": "https://exp.host/--/api/v2/manifest/sign", | ||
} | ||
`); | ||
}); | ||
}); | ||
|
||
describe('getUnsignedManifestString', () => { | ||
it('returns a stringified manifest with the same shape a server-signed manifest', () => { | ||
expect(getUnsignedManifestString(mockManifest)).toMatchSnapshot(); | ||
}); | ||
}); |
3 changes: 3 additions & 0 deletions
3
packages/xdl/src/__tests__/__snapshots__/Project-test.ts.snap
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,3 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`getUnsignedManifestString returns a stringified manifest with the same shape a server-signed manifest 1`] = `"{\\"manifestString\\":\\"{\\\\\\"name\\\\\\":\\\\\\"Hello\\\\\\",\\\\\\"slug\\\\\\":\\\\\\"hello-world\\\\\\",\\\\\\"owner\\\\\\":\\\\\\"ownername\\\\\\",\\\\\\"version\\\\\\":\\\\\\"1.0.0\\\\\\",\\\\\\"platforms\\\\\\":[\\\\\\"ios\\\\\\"]}\\",\\"signature\\":\\"UNSIGNED\\"}"`; |