Skip to content

Commit

Permalink
fix: updates from code review
Browse files Browse the repository at this point in the history
  • Loading branch information
giautm committed Mar 3, 2022
1 parent d024690 commit 44a8698
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 8 deletions.
4 changes: 2 additions & 2 deletions build/preview-comment/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
4 changes: 2 additions & 2 deletions build/setup/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion preview-comment/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand Down
4 changes: 2 additions & 2 deletions src/expo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
20 changes: 19 additions & 1 deletion tests/expo.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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'
);
});
});

0 comments on commit 44a8698

Please sign in to comment.