From 44a86987145b962952e7d5a04480a9d2e0881994 Mon Sep 17 00:00:00 2001 From: "Giau. Tran Minh" Date: Fri, 4 Mar 2022 02:17:41 +0700 Subject: [PATCH] fix: updates from code review --- build/preview-comment/index.js | 4 ++-- build/setup/index.js | 4 ++-- preview-comment/README.md | 2 +- src/expo.ts | 4 ++-- tests/expo.test.ts | 20 +++++++++++++++++++- 5 files changed, 26 insertions(+), 8 deletions(-) diff --git a/build/preview-comment/index.js b/build/preview-comment/index.js index c8842e21..898f1f1f 100644 --- a/build/preview-comment/index.js +++ b/build/preview-comment/index.js @@ -15917,11 +15917,11 @@ function projectLink(project, channel) { } exports.projectLink = projectLink; /** - * Create a deep link for the project in Expo. + * Create a deep link to open the project in Expo Go */ function projectDeepLink(project, channel) { (0, assert_1.ok)(project.owner, 'Could not create a deep link for project without owner'); - const url = new url_1.URL(`exp://expo.host/@${project.owner}/${project.slug}`); + const url = new url_1.URL(`exp://exp.host/@${project.owner}/${project.slug}`); if (channel) { url.searchParams.append('release-channel', channel); } diff --git a/build/setup/index.js b/build/setup/index.js index e61b7052..fe06121a 100644 --- a/build/setup/index.js +++ b/build/setup/index.js @@ -66993,11 +66993,11 @@ function projectLink(project, channel) { } exports.projectLink = projectLink; /** - * Create a deep link for the project in Expo. + * Create a deep link to open the project in Expo Go */ function projectDeepLink(project, channel) { (0, assert_1.ok)(project.owner, 'Could not create a deep link for project without owner'); - const url = new url_1.URL(`exp://expo.host/@${project.owner}/${project.slug}`); + const url = new url_1.URL(`exp://exp.host/@${project.owner}/${project.slug}`); if (channel) { url.searchParams.append('release-channel', channel); } diff --git a/preview-comment/README.md b/preview-comment/README.md index 32d0e385..4fc2cc42 100644 --- a/preview-comment/README.md +++ b/preview-comment/README.md @@ -57,7 +57,7 @@ Here is a summary of these variables. | **projectOwner** | `{projectOwner}` | The resolved owner of the project | | **projectSlug** | `{projectSlug}` | The resolved slug of the project | | **projectName** | `{projectName}` | The resolved name of the project | -| **projectDeepLink** | `{projectDeepLink}` | The expo.host project link, including release channel | +| **projectDeepLink** | `{projectDeepLink}` | A deep link to open the project in Expo Go | | **projectLink** | `{projectLink}` | The expo.dev project link, including release channel | | **projectQR** | `{projectQR}` | The QR code link, to load the project in Expo Go | | - | `{channel}` | The release channel that was used | diff --git a/src/expo.ts b/src/expo.ts index 56166903..8718d972 100644 --- a/src/expo.ts +++ b/src/expo.ts @@ -100,12 +100,12 @@ export function projectLink(project: ProjectInfo, channel?: string): string { } /** - * Create a deep link for the project in Expo. + * Create a deep link to open the project in Expo Go */ export function projectDeepLink(project: ProjectInfo, channel?: string): string { assert(project.owner, 'Could not create a deep link for project without owner'); - const url = new URL(`exp://expo.host/@${project.owner}/${project.slug}`); + const url = new URL(`exp://exp.host/@${project.owner}/${project.slug}`); if (channel) { url.searchParams.append('release-channel', channel); } diff --git a/tests/expo.test.ts b/tests/expo.test.ts index 4e62bc68..6453553c 100644 --- a/tests/expo.test.ts +++ b/tests/expo.test.ts @@ -2,7 +2,7 @@ import * as core from '@actions/core'; import * as exec from '@actions/exec'; import * as io from '@actions/io'; -import { authenticate, projectQR, projectLink } from '../src/expo'; +import { authenticate, projectQR, projectLink, projectDeepLink } from '../src/expo'; jest.mock('@actions/core'); jest.mock('@actions/exec'); @@ -68,3 +68,21 @@ describe(projectLink, () => { ); }); }); + +describe(projectDeepLink, () => { + it('throws when owner is undefined', () => { + expect(() => projectDeepLink({ name: 'fakename', slug: 'fakeslug' })).toThrow('without owner'); + }); + + it('returns url with owner and slug', () => { + expect(projectDeepLink({ name: 'fakename', slug: 'fakeslug', owner: 'fakeowner' })).toBe( + 'exp://exp.host/@fakeowner/fakeslug' + ); + }); + + it('returns url with owner, slug, and release channel', () => { + expect(projectDeepLink({ name: 'fakename', slug: 'fakeslug', owner: 'fakeowner' }, 'fakechannel')).toBe( + 'exp://exp.host/@fakeowner/fakeslug?release-channel=fakechannel' + ); + }); +});