From 7517b65dcd676f36d38f31c991929c32168b3e12 Mon Sep 17 00:00:00 2001 From: João Ferreiro Date: Thu, 22 Dec 2022 15:32:39 +0000 Subject: Unit testing (#32) * add testing lib * remove coverage folder from git * finished basic test setup * fix tests typescript and import paths * add first snapshot * testing utils * rename test files; update script flags; ++tests * testing utils functions * testing downloadAndResize wip * remove download test * specify unwanted coverage paths; remove update snapshots flag * fix strings tests * testing downloadAndResize method * increasing testing * fixing snapshots wip * fixed shell mobile snapshot * adding snapshots for the screens * fix onboard snapshot * fix typescript issues * fix TabsSelector snapshot * Account for testing device's locale in ago() tests * Remove platform detection on regex Co-authored-by: Paul Frazee --- __tests__/App-test.tsx | 16 - __tests__/lib/download.test.ts | 93 +++ __tests__/lib/errors.test.ts | 19 + __tests__/lib/link-meta.test.ts | 146 ++++ __tests__/lib/numbers.test.ts | 24 + __tests__/lib/string.test.ts | 532 +++++++++++++ __tests__/link-meta-utils.ts | 118 --- __tests__/string-utils.ts | 319 -------- __tests__/view/screens/Contacts.test.tsx | 16 + __tests__/view/screens/Home.test.tsx | 16 + __tests__/view/screens/Login.test.tsx | 11 + __tests__/view/screens/NotFound.test.tsx | 11 + __tests__/view/screens/Notifications.test.tsx | 16 + __tests__/view/screens/Onboard.test.tsx | 11 + __tests__/view/screens/PostDownvotedBy.test.tsx | 19 + __tests__/view/screens/PostRepostedBy.test.tsx | 19 + __tests__/view/screens/PostThread.test.tsx | 19 + __tests__/view/screens/PostUpvotedBy.test.tsx | 19 + __tests__/view/screens/Profile.test.tsx | 19 + __tests__/view/screens/ProfileFollowers.test.tsx | 18 + __tests__/view/screens/ProfileFollows.test.tsx | 18 + __tests__/view/screens/ProfileMembers.test.tsx | 18 + __tests__/view/screens/Search.test.tsx | 18 + __tests__/view/screens/Settings.test.tsx | 16 + .../screens/__snapshots__/Contacts.test.tsx.snap | 205 +++++ .../view/screens/__snapshots__/Home.test.tsx.snap | 594 +++++++++++++++ .../view/screens/__snapshots__/Login.test.tsx.snap | 371 +++++++++ .../screens/__snapshots__/NotFound.test.tsx.snap | 431 +++++++++++ .../__snapshots__/Notifications.test.tsx.snap | 378 ++++++++++ .../screens/__snapshots__/Onboard.test.tsx.snap | 388 ++++++++++ .../__snapshots__/PostDownvotedBy.test.tsx.snap | 368 +++++++++ .../__snapshots__/PostRepostedBy.test.tsx.snap | 368 +++++++++ .../screens/__snapshots__/PostThread.test.tsx.snap | 437 +++++++++++ .../__snapshots__/PostUpvotedBy.test.tsx.snap | 368 +++++++++ .../screens/__snapshots__/Profile.test.tsx.snap | 513 +++++++++++++ .../__snapshots__/ProfileFollowers.test.tsx.snap | 386 ++++++++++ .../__snapshots__/ProfileFollows.test.tsx.snap | 386 ++++++++++ .../__snapshots__/ProfileMembers.test.tsx.snap | 386 ++++++++++ .../screens/__snapshots__/Search.test.tsx.snap | 514 +++++++++++++ .../screens/__snapshots__/Settings.test.tsx.snap | 631 ++++++++++++++++ __tests__/view/shell/mobile/Composer.test.tsx | 23 + __tests__/view/shell/mobile/Menu.test.tsx | 15 + __tests__/view/shell/mobile/TabsSelector.test.tsx | 17 + .../mobile/__snapshots__/Composer.test.tsx.snap | 659 ++++++++++++++++ .../shell/mobile/__snapshots__/Menu.test.tsx.snap | 837 +++++++++++++++++++++ .../__snapshots__/TabsSelector.test.tsx.snap | 651 ++++++++++++++++ .../shell/mobile/__snapshots__/index.test.tsx.snap | 421 +++++++++++ __tests__/view/shell/mobile/index.test.tsx | 18 + 48 files changed, 10443 insertions(+), 453 deletions(-) delete mode 100644 __tests__/App-test.tsx create mode 100644 __tests__/lib/download.test.ts create mode 100644 __tests__/lib/errors.test.ts create mode 100644 __tests__/lib/link-meta.test.ts create mode 100644 __tests__/lib/numbers.test.ts create mode 100644 __tests__/lib/string.test.ts delete mode 100644 __tests__/link-meta-utils.ts delete mode 100644 __tests__/string-utils.ts create mode 100644 __tests__/view/screens/Contacts.test.tsx create mode 100644 __tests__/view/screens/Home.test.tsx create mode 100644 __tests__/view/screens/Login.test.tsx create mode 100644 __tests__/view/screens/NotFound.test.tsx create mode 100644 __tests__/view/screens/Notifications.test.tsx create mode 100644 __tests__/view/screens/Onboard.test.tsx create mode 100644 __tests__/view/screens/PostDownvotedBy.test.tsx create mode 100644 __tests__/view/screens/PostRepostedBy.test.tsx create mode 100644 __tests__/view/screens/PostThread.test.tsx create mode 100644 __tests__/view/screens/PostUpvotedBy.test.tsx create mode 100644 __tests__/view/screens/Profile.test.tsx create mode 100644 __tests__/view/screens/ProfileFollowers.test.tsx create mode 100644 __tests__/view/screens/ProfileFollows.test.tsx create mode 100644 __tests__/view/screens/ProfileMembers.test.tsx create mode 100644 __tests__/view/screens/Search.test.tsx create mode 100644 __tests__/view/screens/Settings.test.tsx create mode 100644 __tests__/view/screens/__snapshots__/Contacts.test.tsx.snap create mode 100644 __tests__/view/screens/__snapshots__/Home.test.tsx.snap create mode 100644 __tests__/view/screens/__snapshots__/Login.test.tsx.snap create mode 100644 __tests__/view/screens/__snapshots__/NotFound.test.tsx.snap create mode 100644 __tests__/view/screens/__snapshots__/Notifications.test.tsx.snap create mode 100644 __tests__/view/screens/__snapshots__/Onboard.test.tsx.snap create mode 100644 __tests__/view/screens/__snapshots__/PostDownvotedBy.test.tsx.snap create mode 100644 __tests__/view/screens/__snapshots__/PostRepostedBy.test.tsx.snap create mode 100644 __tests__/view/screens/__snapshots__/PostThread.test.tsx.snap create mode 100644 __tests__/view/screens/__snapshots__/PostUpvotedBy.test.tsx.snap create mode 100644 __tests__/view/screens/__snapshots__/Profile.test.tsx.snap create mode 100644 __tests__/view/screens/__snapshots__/ProfileFollowers.test.tsx.snap create mode 100644 __tests__/view/screens/__snapshots__/ProfileFollows.test.tsx.snap create mode 100644 __tests__/view/screens/__snapshots__/ProfileMembers.test.tsx.snap create mode 100644 __tests__/view/screens/__snapshots__/Search.test.tsx.snap create mode 100644 __tests__/view/screens/__snapshots__/Settings.test.tsx.snap create mode 100644 __tests__/view/shell/mobile/Composer.test.tsx create mode 100644 __tests__/view/shell/mobile/Menu.test.tsx create mode 100644 __tests__/view/shell/mobile/TabsSelector.test.tsx create mode 100644 __tests__/view/shell/mobile/__snapshots__/Composer.test.tsx.snap create mode 100644 __tests__/view/shell/mobile/__snapshots__/Menu.test.tsx.snap create mode 100644 __tests__/view/shell/mobile/__snapshots__/TabsSelector.test.tsx.snap create mode 100644 __tests__/view/shell/mobile/__snapshots__/index.test.tsx.snap create mode 100644 __tests__/view/shell/mobile/index.test.tsx (limited to '__tests__') diff --git a/__tests__/App-test.tsx b/__tests__/App-test.tsx deleted file mode 100644 index db34ec617..000000000 --- a/__tests__/App-test.tsx +++ /dev/null @@ -1,16 +0,0 @@ -// /** -// * @format -// */ - -// import 'react-native' -// import React from 'react' -// import App from '../src/App' - -// // Note: test renderer must be required after react-native. -// import renderer from 'react-test-renderer' - -// it('renders correctly', () => { -// renderer.act(() => { -// renderer.create() -// }) -// }) diff --git a/__tests__/lib/download.test.ts b/__tests__/lib/download.test.ts new file mode 100644 index 000000000..d90e8c895 --- /dev/null +++ b/__tests__/lib/download.test.ts @@ -0,0 +1,93 @@ +import {downloadAndResize, DownloadAndResizeOpts} from '../../src/lib/download' +import ImageResizer from '@bam.tech/react-native-image-resizer' +import RNFetchBlob from 'rn-fetch-blob' + +jest.mock('rn-fetch-blob', () => ({ + config: jest.fn().mockReturnThis(), + cancel: jest.fn(), + fetch: jest.fn(), +})) +jest.mock('@bam.tech/react-native-image-resizer', () => ({ + createResizedImage: jest.fn(), +})) + +describe('downloadAndResize', () => { + const errorSpy = jest.spyOn(global.console, 'error') + + const mockResizedImage = { + path: jest.fn().mockReturnValue('file://resized-image.jpg'), + } + + beforeEach(() => { + jest.clearAllMocks() + + const mockedCreateResizedImage = + ImageResizer.createResizedImage as jest.Mock + mockedCreateResizedImage.mockResolvedValue(mockResizedImage) + }) + + it('should return resized image for valid URI and options', async () => { + const mockedFetch = RNFetchBlob.fetch as jest.Mock + mockedFetch.mockResolvedValueOnce({ + path: jest.fn().mockReturnValue('file://downloaded-image.jpg'), + flush: jest.fn(), + }) + + const opts: DownloadAndResizeOpts = { + uri: 'https://example.com/image.jpg', + width: 100, + height: 100, + mode: 'cover', + timeout: 10000, + } + + const result = await downloadAndResize(opts) + expect(result).toEqual(mockResizedImage) + expect(RNFetchBlob.config).toHaveBeenCalledWith({ + fileCache: true, + appendExt: 'jpeg', + }) + expect(RNFetchBlob.fetch).toHaveBeenCalledWith( + 'GET', + 'https://example.com/image.jpg', + ) + expect(ImageResizer.createResizedImage).toHaveBeenCalledWith( + 'file://downloaded-image.jpg', + 100, + 100, + 'JPEG', + 0.7, + undefined, + undefined, + undefined, + {mode: 'cover'}, + ) + }) + + it('should return undefined for invalid URI', async () => { + const opts: DownloadAndResizeOpts = { + uri: 'invalid-uri', + width: 100, + height: 100, + mode: 'cover', + timeout: 10000, + } + + const result = await downloadAndResize(opts) + expect(errorSpy).toHaveBeenCalled() + expect(result).toBeUndefined() + }) + + it('should return undefined for unsupported file type', async () => { + const opts: DownloadAndResizeOpts = { + uri: 'https://example.com/image.bmp', + width: 100, + height: 100, + mode: 'cover', + timeout: 10000, + } + + const result = await downloadAndResize(opts) + expect(result).toBeUndefined() + }) +}) diff --git a/__tests__/lib/errors.test.ts b/__tests__/lib/errors.test.ts new file mode 100644 index 000000000..b9549e6d8 --- /dev/null +++ b/__tests__/lib/errors.test.ts @@ -0,0 +1,19 @@ +import {isNetworkError} from '../../src/lib/errors' + +describe('isNetworkError', () => { + const inputs = [ + 'TypeError: Network request failed', + 'Uncaught TypeError: Cannot read property x of undefined', + 'Uncaught RangeError', + 'Error: Aborted', + ] + const outputs = [true, false, false, true] + + it('correctly distinguishes network errors', () => { + for (let i = 0; i < inputs.length; i++) { + const input = inputs[i] + const result = isNetworkError(input) + expect(result).toEqual(outputs[i]) + } + }) +}) diff --git a/__tests__/lib/link-meta.test.ts b/__tests__/lib/link-meta.test.ts new file mode 100644 index 000000000..5df5153ee --- /dev/null +++ b/__tests__/lib/link-meta.test.ts @@ -0,0 +1,146 @@ +import {LikelyType, getLinkMeta, getLikelyType} from '../../src/lib/link-meta' + +const exampleComHtml = ` + + + Example Domain + + + + + + + + + +
+

Example Domain

+

This domain is for use in illustrative examples in documents. You may use this + domain in literature without prior coordination or asking for permission.

+

More information...

+
+ +` + +describe('getLinkMeta', () => { + const inputs = [ + '', + 'httpbadurl', + 'https://example.com', + 'https://example.com/index.html', + 'https://example.com/image.png', + 'https://example.com/video.avi', + 'https://example.com/audio.ogg', + 'https://example.com/text.txt', + 'https://example.com/javascript.js', + 'https://bsky.app/index.html', + ] + const outputs = [ + { + error: 'Invalid URL', + likelyType: LikelyType.Other, + url: '', + }, + { + error: 'Invalid URL', + likelyType: LikelyType.Other, + url: 'httpbadurl', + }, + { + likelyType: LikelyType.HTML, + url: 'https://example.com', + title: 'Example Domain', + description: 'An example website', + }, + { + likelyType: LikelyType.HTML, + url: 'https://example.com/index.html', + title: 'Example Domain', + description: 'An example website', + }, + { + likelyType: LikelyType.Image, + url: 'https://example.com/image.png', + }, + { + likelyType: LikelyType.Video, + url: 'https://example.com/video.avi', + }, + { + likelyType: LikelyType.Audio, + url: 'https://example.com/audio.ogg', + }, + { + likelyType: LikelyType.Text, + url: 'https://example.com/text.txt', + }, + { + likelyType: LikelyType.Other, + url: 'https://example.com/javascript.js', + }, + { + likelyType: LikelyType.AtpData, + url: '/index.html', + title: 'Not found', + }, + { + likelyType: LikelyType.Other, + url: '', + title: '', + }, + ] + it('correctly handles a set of text inputs', async () => { + for (let i = 0; i < inputs.length; i++) { + global.fetch = jest.fn().mockImplementationOnce(() => { + return new Promise((resolve, _reject) => { + resolve({ + ok: true, + status: 200, + text: () => exampleComHtml, + }) + }) + }) + const input = inputs[i] + const output = await getLinkMeta(input) + expect(output).toEqual(outputs[i]) + } + }) +}) + +describe('getLikelyType', () => { + it('correctly handles non-parsed url', async () => { + const output = await getLikelyType('https://example.com') + expect(output).toEqual(LikelyType.HTML) + }) + + it('handles non-string urls without crashing', async () => { + const output = await getLikelyType('123') + expect(output).toEqual(LikelyType.Other) + }) +}) diff --git a/__tests__/lib/numbers.test.ts b/__tests__/lib/numbers.test.ts new file mode 100644 index 000000000..be92d6c0f --- /dev/null +++ b/__tests__/lib/numbers.test.ts @@ -0,0 +1,24 @@ +import {clamp} from '../../src/lib/numbers' + +describe('clamp', () => { + const inputs: [number, number, number][] = [ + [100, 0, 200], + [100, 0, 100], + [0, 0, 100], + [100, 0, -1], + [4, 1, 1], + [100, -100, 0], + [400, 100, -100], + [70, -1, 1], + [Infinity, Infinity, Infinity], + ] + const outputs = [100, 100, 0, -1, 1, 0, -100, 1, Infinity] + + it('correctly clamps any given number and range', () => { + for (let i = 0; i < inputs.length; i++) { + const input = inputs[i] + const result = clamp(...input) + expect(result).toEqual(outputs[i]) + } + }) +}) diff --git a/__tests__/lib/string.test.ts b/__tests__/lib/string.test.ts new file mode 100644 index 000000000..d8a56b36b --- /dev/null +++ b/__tests__/lib/string.test.ts @@ -0,0 +1,532 @@ +import { + extractEntities, + detectLinkables, + extractHtmlMeta, + pluralize, + makeRecordUri, + ago, + makeValidHandle, + createFullHandle, + enforceLen, + cleanError, + toNiceDomain, + toShortUrl, + toShareUrl, +} from '../../src/lib/strings' + +describe('extractEntities', () => { + const knownHandles = new Set(['handle.com', 'full123.test-of-chars']) + const inputs = [ + 'no mention', + '@handle.com middle end', + 'start @handle.com end', + 'start middle @handle.com', + '@handle.com @handle.com @handle.com', + '@full123.test-of-chars', + 'not@right', + '@handle.com!@#$chars', + '@handle.com\n@handle.com', + 'parenthetical (@handle.com)', + 'start https://middle.com end', + 'start https://middle.com/foo/bar end', + 'start https://middle.com/foo/bar?baz=bux end', + 'start https://middle.com/foo/bar?baz=bux#hash end', + 'https://start.com/foo/bar?baz=bux#hash middle end', + 'start middle https://end.com/foo/bar?baz=bux#hash', + 'https://newline1.com\nhttps://newline2.com', + 'start middle.com end', + 'start middle.com/foo/bar end', + 'start middle.com/foo/bar?baz=bux end', + 'start middle.com/foo/bar?baz=bux#hash end', + 'start.com/foo/bar?baz=bux#hash middle end', + 'start middle end.com/foo/bar?baz=bux#hash', + 'newline1.com\nnewline2.com', + 'not.. a..url ..here', + 'e.g.', + 'something-cool.jpg', + 'website.com.jpg', + 'e.g./foo', + 'website.com.jpg/foo', + 'Classic article https://socket3.wordpress.com/2018/02/03/designing-windows-95s-user-interface/', + 'Classic article https://socket3.wordpress.com/2018/02/03/designing-windows-95s-user-interface/ ', + 'https://foo.com https://bar.com/whatever https://baz.com', + 'punctuation https://foo.com, https://bar.com/whatever; https://baz.com.', + 'parenthentical (https://foo.com)', + 'except for https://foo.com/thing_(cool)', + ] + interface Output { + type: string + value: string + noScheme?: boolean + } + const outputs: Output[][] = [ + [], + [{type: 'mention', value: 'handle.com'}], + [{type: 'mention', value: 'handle.com'}], + [{type: 'mention', value: 'handle.com'}], + [ + {type: 'mention', value: 'handle.com'}, + {type: 'mention', value: 'handle.com'}, + {type: 'mention', value: 'handle.com'}, + ], + [ + { + type: 'mention', + value: 'full123.test-of-chars', + }, + ], + [], + [{type: 'mention', value: 'handle.com'}], + [ + {type: 'mention', value: 'handle.com'}, + {type: 'mention', value: 'handle.com'}, + ], + [{type: 'mention', value: 'handle.com'}], + [{type: 'link', value: 'https://middle.com'}], + [{type: 'link', value: 'https://middle.com/foo/bar'}], + [{type: 'link', value: 'https://middle.com/foo/bar?baz=bux'}], + [{type: 'link', value: 'https://middle.com/foo/bar?baz=bux#hash'}], + [{type: 'link', value: 'https://start.com/foo/bar?baz=bux#hash'}], + [{type: 'link', value: 'https://end.com/foo/bar?baz=bux#hash'}], + [ + {type: 'link', value: 'https://newline1.com'}, + {type: 'link', value: 'https://newline2.com'}, + ], + [{type: 'link', value: 'middle.com', noScheme: true}], + [{type: 'link', value: 'middle.com/foo/bar', noScheme: true}], + [{type: 'link', value: 'middle.com/foo/bar?baz=bux', noScheme: true}], + [{type: 'link', value: 'middle.com/foo/bar?baz=bux#hash', noScheme: true}], + [{type: 'link', value: 'start.com/foo/bar?baz=bux#hash', noScheme: true}], + [{type: 'link', value: 'end.com/foo/bar?baz=bux#hash', noScheme: true}], + [ + {type: 'link', value: 'newline1.com', noScheme: true}, + {type: 'link', value: 'newline2.com', noScheme: true}, + ], + [], + [], + [], + [], + [], + [], + [ + { + type: 'link', + value: + 'https://socket3.wordpress.com/2018/02/03/designing-windows-95s-user-interface/', + }, + ], + [ + { + type: 'link', + value: + 'https://socket3.wordpress.com/2018/02/03/designing-windows-95s-user-interface/', + }, + ], + [ + {type: 'link', value: 'https://foo.com'}, + {type: 'link', value: 'https://bar.com/whatever'}, + {type: 'link', value: 'https://baz.com'}, + ], + [ + {type: 'link', value: 'https://foo.com'}, + {type: 'link', value: 'https://bar.com/whatever'}, + {type: 'link', value: 'https://baz.com'}, + ], + [{type: 'link', value: 'https://foo.com'}], + [{type: 'link', value: 'https://foo.com/thing_(cool)'}], + ] + it('correctly handles a set of text inputs', () => { + for (let i = 0; i < inputs.length; i++) { + const input = inputs[i] + const result = extractEntities(input, knownHandles) + if (!outputs[i].length) { + expect(result).toBeFalsy() + } else if (outputs[i].length && !result) { + expect(result).toBeTruthy() + } else if (result) { + expect(result.length).toBe(outputs[i].length) + for (let j = 0; j < outputs[i].length; j++) { + expect(result[j].type).toEqual(outputs[i][j].type) + if (outputs[i][j].noScheme) { + expect(result[j].value).toEqual(`https://${outputs[i][j].value}`) + } else { + expect(result[j].value).toEqual(outputs[i][j].value) + } + if (outputs[i]?.[j].type === 'mention') { + expect( + input.slice(result[j].index.start, result[j].index.end), + ).toBe(`@${result[j].value}`) + } else { + if (!outputs[i]?.[j].noScheme) { + expect( + input.slice(result[j].index.start, result[j].index.end), + ).toBe(result[j].value) + } else { + expect( + input.slice(result[j].index.start, result[j].index.end), + ).toBe(result[j].value.slice('https://'.length)) + } + } + } + } + } + }) +}) + +describe('detectLinkables', () => { + const inputs = [ + 'no linkable', + '@start middle end', + 'start @middle end', + 'start middle @end', + '@start @middle @end', + '@full123.test-of-chars', + 'not@right', + '@bad!@#$chars', + '@newline1\n@newline2', + 'parenthetical (@handle)', + 'start https://middle.com end', + 'start https://middle.com/foo/bar end', + 'start https://middle.com/foo/bar?baz=bux end', + 'start https://middle.com/foo/bar?baz=bux#hash end', + 'https://start.com/foo/bar?baz=bux#hash middle end', + 'start middle https://end.com/foo/bar?baz=bux#hash', + 'https://newline1.com\nhttps://newline2.com', + 'start middle.com end', + 'start middle.com/foo/bar end', + 'start middle.com/foo/bar?baz=bux end', + 'start middle.com/foo/bar?baz=bux#hash end', + 'start.com/foo/bar?baz=bux#hash middle end', + 'start middle end.com/foo/bar?baz=bux#hash', + 'newline1.com\nnewline2.com', + 'not.. a..url ..here', + 'e.g.', + 'e.g. real.com fake.notreal', + 'something-cool.jpg', + 'website.com.jpg', + 'e.g./foo', + 'website.com.jpg/foo', + 'Classic article https://socket3.wordpress.com/2018/02/03/designing-windows-95s-user-interface/', + 'Classic article https://socket3.wordpress.com/2018/02/03/designing-windows-95s-user-interface/ ', + 'https://foo.com https://bar.com/whatever https://baz.com', + 'punctuation https://foo.com, https://bar.com/whatever; https://baz.com.', + 'parenthentical (https://foo.com)', + 'except for https://foo.com/thing_(cool)', + ] + const outputs = [ + ['no linkable'], + [{link: '@start'}, ' middle end'], + ['start ', {link: '@middle'}, ' end'], + ['start middle ', {link: '@end'}], + [{link: '@start'}, ' ', {link: '@middle'}, ' ', {link: '@end'}], + [{link: '@full123.test-of-chars'}], + ['not@right'], + [{link: '@bad'}, '!@#$chars'], + [{link: '@newline1'}, '\n', {link: '@newline2'}], + ['parenthetical (', {link: '@handle'}, ')'], + ['start ', {link: 'https://middle.com'}, ' end'], + ['start ', {link: 'https://middle.com/foo/bar'}, ' end'], + ['start ', {link: 'https://middle.com/foo/bar?baz=bux'}, ' end'], + ['start ', {link: 'https://middle.com/foo/bar?baz=bux#hash'}, ' end'], + [{link: 'https://start.com/foo/bar?baz=bux#hash'}, ' middle end'], + ['start middle ', {link: 'https://end.com/foo/bar?baz=bux#hash'}], + [{link: 'https://newline1.com'}, '\n', {link: 'https://newline2.com'}], + ['start ', {link: 'middle.com'}, ' end'], + ['start ', {link: 'middle.com/foo/bar'}, ' end'], + ['start ', {link: 'middle.com/foo/bar?baz=bux'}, ' end'], + ['start ', {link: 'middle.com/foo/bar?baz=bux#hash'}, ' end'], + [{link: 'start.com/foo/bar?baz=bux#hash'}, ' middle end'], + ['start middle ', {link: 'end.com/foo/bar?baz=bux#hash'}], + [{link: 'newline1.com'}, '\n', {link: 'newline2.com'}], + ['not.. a..url ..here'], + ['e.g.'], + ['e.g. ', {link: 'real.com'}, ' fake.notreal'], + ['something-cool.jpg'], + ['website.com.jpg'], + ['e.g./foo'], + ['website.com.jpg/foo'], + [ + 'Classic article ', + { + link: 'https://socket3.wordpress.com/2018/02/03/designing-windows-95s-user-interface/', + }, + ], + [ + 'Classic article ', + { + link: 'https://socket3.wordpress.com/2018/02/03/designing-windows-95s-user-interface/', + }, + ' ', + ], + [ + {link: 'https://foo.com'}, + ' ', + {link: 'https://bar.com/whatever'}, + ' ', + {link: 'https://baz.com'}, + ], + [ + 'punctuation ', + {link: 'https://foo.com'}, + ', ', + {link: 'https://bar.com/whatever'}, + '; ', + {link: 'https://baz.com'}, + '.', + ], + ['parenthentical (', {link: 'https://foo.com'}, ')'], + ['except for ', {link: 'https://foo.com/thing_(cool)'}], + ] + it('correctly handles a set of text inputs', () => { + for (let i = 0; i < inputs.length; i++) { + const input = inputs[i] + const output = detectLinkables(input) + expect(output).toEqual(outputs[i]) + } + }) +}) + +describe('extractHtmlMeta', () => { + const inputs = [ + '', + 'nothing', + 'title', + ' aSd!@#AC ', + '\n title\n ', + '', + '', + '', + '', + '', + '', + '', + '', + '', + ] + const outputs = [ + {}, + {}, + {title: 'title'}, + {title: 'aSd!@#AC'}, + {title: 'title'}, + {title: 'meta title'}, + {description: 'meta description'}, + {title: 'og title'}, + {description: 'og description'}, + {image: 'https://ogimage.com/foo.png'}, + {title: 'twitter title'}, + {description: 'twitter description'}, + {image: 'https://twitterimage.com/foo.png'}, + {title: 'meta title'}, + ] + it('correctly handles a set of text inputs', () => { + for (let i = 0; i < inputs.length; i++) { + const input = inputs[i] + const output = extractHtmlMeta(input) + expect(output).toEqual(outputs[i]) + } + }) +}) + +describe('pluralize', () => { + const inputs: [number, string, string?][] = [ + [1, 'follower'], + [1, 'member'], + [100, 'post'], + [1000, 'repost'], + [10000, 'upvote'], + [100000, 'other'], + [2, 'man', 'men'], + ] + const outputs = [ + 'follower', + 'member', + 'posts', + 'reposts', + 'upvotes', + 'others', + 'men', + ] + + it('correctly pluralizes a set of words', () => { + for (let i = 0; i < inputs.length; i++) { + const input = inputs[i] + const output = pluralize(...input) + expect(output).toEqual(outputs[i]) + } + }) +}) + +describe('makeRecordUri', () => { + const inputs: [string, string, string][] = [ + ['alice.test', 'app.bsky.feed.post', '3jk7x4irgv52r'], + ] + const outputs = ['at://alice.test/app.bsky.feed.post/3jk7x4irgv52r'] + + it('correctly builds a record URI', () => { + for (let i = 0; i < inputs.length; i++) { + const input = inputs[i] + const result = makeRecordUri(...input) + expect(result).toEqual(outputs[i]) + } + }) +}) + +describe('ago', () => { + const inputs = [ + 1671461038, + '04 Dec 1995 00:12:00 GMT', + new Date(), + new Date().setMinutes(new Date().getMinutes() - 10), + new Date().setHours(new Date().getHours() - 1), + new Date().setDate(new Date().getDate() - 1), + new Date().setMonth(new Date().getMonth() - 1), + ] + const outputs = [ + new Date(1671461038).toLocaleDateString(), + new Date('04 Dec 1995 00:12:00 GMT').toLocaleDateString(), + '0s', + '10m', + '1h', + '1d', + '1mo', + ] + + it('correctly calculates how much time passed, in a string', () => { + for (let i = 0; i < inputs.length; i++) { + const result = ago(inputs[i]) + expect(result).toEqual(outputs[i]) + } + }) +}) + +describe('makeValidHandle', () => { + const inputs = [ + 'test-handle-123', + 'test!"#$%&/()=?_', + 'this-handle-should-be-too-big', + ] + const outputs = ['test-handle-123', 'test', 'this-handle-should-b'] + + it('correctly parses and corrects handles', () => { + for (let i = 0; i < inputs.length; i++) { + const result = makeValidHandle(inputs[i]) + expect(result).toEqual(outputs[i]) + } + }) +}) + +describe('createFullHandle', () => { + const inputs: [string, string][] = [ + ['test-handle-123', 'test'], + ['.test.handle', 'test.test.'], + ['test.handle.', '.test.test'], + ] + const outputs = [ + 'test-handle-123.test', + '.test.handle.test.test.', + 'test.handle.test.test', + ] + + it('correctly parses and corrects handles', () => { + for (let i = 0; i < inputs.length; i++) { + const input = inputs[i] + const result = createFullHandle(...input) + expect(result).toEqual(outputs[i]) + } + }) +}) + +describe('enforceLen', () => { + const inputs: [string, number][] = [ + ['Hello World!', 5], + ['Hello World!', 20], + ['', 5], + ] + const outputs = ['Hello', 'Hello World!', ''] + + it('correctly enforces defined length on a given string', () => { + for (let i = 0; i < inputs.length; i++) { + const input = inputs[i] + const result = enforceLen(...input) + expect(result).toEqual(outputs[i]) + } + }) +}) + +describe('cleanError', () => { + const inputs = [ + 'TypeError: Network request failed', + 'Error: Aborted', + 'Error: TypeError "x" is not a function', + 'Error: SyntaxError unexpected token "export"', + 'Some other error', + ] + const outputs = [ + 'Unable to connect. Please check your internet connection and try again.', + 'Unable to connect. Please check your internet connection and try again.', + 'TypeError "x" is not a function', + 'SyntaxError unexpected token "export"', + 'Some other error', + ] + + it('removes extra content from error message', () => { + for (let i = 0; i < inputs.length; i++) { + const result = cleanError(inputs[i]) + expect(result).toEqual(outputs[i]) + } + }) +}) + +describe('toNiceDomain', () => { + const inputs = [ + 'https://example.com/index.html', + 'https://bsky.app', + 'https://bsky.social', + '#123123123', + ] + const outputs = ['example.com', 'bsky.app', 'Bluesky Social', '#123123123'] + + it("displays the url's host in a easily readable manner", () => { + for (let i = 0; i < inputs.length; i++) { + const result = toNiceDomain(inputs[i]) + expect(result).toEqual(outputs[i]) + } + }) +}) + +describe('toShortUrl', () => { + const inputs = [ + 'https://bsky.app', + 'https://bsky.app/3jk7x4irgv52r', + 'https://bsky.app/3jk7x4irgv52r2313y182h9', + ] + const outputs = [ + 'bsky.app', + 'bsky.app/3jk7x4irgv52r', + 'bsky.app/3jk7x4irgv52r2313y...', + ] + + it('shortens the url', () => { + for (let i = 0; i < inputs.length; i++) { + const result = toShortUrl(inputs[i]) + expect(result).toEqual(outputs[i]) + } + }) +}) + +describe('toShareUrl', () => { + const inputs = ['https://bsky.app', '/3jk7x4irgv52r', 'item/test/123'] + const outputs = [ + 'https://bsky.app', + 'https://bsky.app/3jk7x4irgv52r', + 'https://bsky.app/item/test/123', + ] + + it('appends https, when not present', () => { + for (let i = 0; i < inputs.length; i++) { + const result = toShareUrl(inputs[i]) + expect(result).toEqual(outputs[i]) + } + }) +}) diff --git a/__tests__/link-meta-utils.ts b/__tests__/link-meta-utils.ts deleted file mode 100644 index f6cf8b4fd..000000000 --- a/__tests__/link-meta-utils.ts +++ /dev/null @@ -1,118 +0,0 @@ -import {LikelyType, getLinkMeta} from '../src/lib/link-meta' - -const exampleComHtml = ` - - - Example Domain - - - - - - - - - -
-

Example Domain

-

This domain is for use in illustrative examples in documents. You may use this - domain in literature without prior coordination or asking for permission.

-

More information...

-
- -` - -describe('getLinkMeta', () => { - const inputs = [ - '', - 'httpbadurl', - 'https://example.com', - 'https://example.com/index.html', - 'https://example.com/image.png', - 'https://example.com/video.avi', - 'https://example.com/audio.ogg', - 'https://example.com/javascript.js', - ] - const outputs = [ - { - error: 'Invalid URL', - likelyType: LikelyType.Other, - url: '', - }, - { - error: 'Invalid URL', - likelyType: LikelyType.Other, - url: 'httpbadurl', - }, - { - likelyType: LikelyType.HTML, - url: 'https://example.com', - title: 'Example Domain', - description: 'An example website', - }, - { - likelyType: LikelyType.HTML, - url: 'https://example.com/index.html', - title: 'Example Domain', - description: 'An example website', - }, - { - likelyType: LikelyType.Image, - url: 'https://example.com/image.png', - }, - { - likelyType: LikelyType.Video, - url: 'https://example.com/video.avi', - }, - { - likelyType: LikelyType.Audio, - url: 'https://example.com/audio.ogg', - }, - { - likelyType: LikelyType.Other, - url: 'https://example.com/javascript.js', - }, - ] - it('correctly handles a set of text inputs', async () => { - for (let i = 0; i < inputs.length; i++) { - global.fetch = jest.fn().mockImplementationOnce(() => { - return new Promise((resolve, reject) => { - resolve({ - ok: true, - status: 200, - text: () => exampleComHtml, - }) - }) - }) - const input = inputs[i] - const output = await getLinkMeta(input) - expect(output).toEqual(outputs[i]) - } - }) -}) diff --git a/__tests__/string-utils.ts b/__tests__/string-utils.ts deleted file mode 100644 index a1bd59fee..000000000 --- a/__tests__/string-utils.ts +++ /dev/null @@ -1,319 +0,0 @@ -import { - extractEntities, - detectLinkables, - extractHtmlMeta, -} from '../src/lib/strings' - -describe('extractEntities', () => { - const knownHandles = new Set(['handle.com', 'full123.test-of-chars']) - const inputs = [ - 'no mention', - '@handle.com middle end', - 'start @handle.com end', - 'start middle @handle.com', - '@handle.com @handle.com @handle.com', - '@full123.test-of-chars', - 'not@right', - '@handle.com!@#$chars', - '@handle.com\n@handle.com', - 'parenthetical (@handle.com)', - 'start https://middle.com end', - 'start https://middle.com/foo/bar end', - 'start https://middle.com/foo/bar?baz=bux end', - 'start https://middle.com/foo/bar?baz=bux#hash end', - 'https://start.com/foo/bar?baz=bux#hash middle end', - 'start middle https://end.com/foo/bar?baz=bux#hash', - 'https://newline1.com\nhttps://newline2.com', - 'start middle.com end', - 'start middle.com/foo/bar end', - 'start middle.com/foo/bar?baz=bux end', - 'start middle.com/foo/bar?baz=bux#hash end', - 'start.com/foo/bar?baz=bux#hash middle end', - 'start middle end.com/foo/bar?baz=bux#hash', - 'newline1.com\nnewline2.com', - 'not.. a..url ..here', - 'e.g.', - 'something-cool.jpg', - 'website.com.jpg', - 'e.g./foo', - 'website.com.jpg/foo', - 'Classic article https://socket3.wordpress.com/2018/02/03/designing-windows-95s-user-interface/', - 'Classic article https://socket3.wordpress.com/2018/02/03/designing-windows-95s-user-interface/ ', - 'https://foo.com https://bar.com/whatever https://baz.com', - 'punctuation https://foo.com, https://bar.com/whatever; https://baz.com.', - 'parenthentical (https://foo.com)', - 'except for https://foo.com/thing_(cool)', - ] - interface Output { - type: string - value: string - noScheme?: boolean - } - const outputs: Output[][] = [ - [], - [{type: 'mention', value: 'handle.com'}], - [{type: 'mention', value: 'handle.com'}], - [{type: 'mention', value: 'handle.com'}], - [ - {type: 'mention', value: 'handle.com'}, - {type: 'mention', value: 'handle.com'}, - {type: 'mention', value: 'handle.com'}, - ], - [ - { - type: 'mention', - value: 'full123.test-of-chars', - }, - ], - [], - [{type: 'mention', value: 'handle.com'}], - [ - {type: 'mention', value: 'handle.com'}, - {type: 'mention', value: 'handle.com'}, - ], - [{type: 'mention', value: 'handle.com'}], - [{type: 'link', value: 'https://middle.com'}], - [{type: 'link', value: 'https://middle.com/foo/bar'}], - [{type: 'link', value: 'https://middle.com/foo/bar?baz=bux'}], - [{type: 'link', value: 'https://middle.com/foo/bar?baz=bux#hash'}], - [{type: 'link', value: 'https://start.com/foo/bar?baz=bux#hash'}], - [{type: 'link', value: 'https://end.com/foo/bar?baz=bux#hash'}], - [ - {type: 'link', value: 'https://newline1.com'}, - {type: 'link', value: 'https://newline2.com'}, - ], - [{type: 'link', value: 'middle.com', noScheme: true}], - [{type: 'link', value: 'middle.com/foo/bar', noScheme: true}], - [{type: 'link', value: 'middle.com/foo/bar?baz=bux', noScheme: true}], - [{type: 'link', value: 'middle.com/foo/bar?baz=bux#hash', noScheme: true}], - [{type: 'link', value: 'start.com/foo/bar?baz=bux#hash', noScheme: true}], - [{type: 'link', value: 'end.com/foo/bar?baz=bux#hash', noScheme: true}], - [ - {type: 'link', value: 'newline1.com', noScheme: true}, - {type: 'link', value: 'newline2.com', noScheme: true}, - ], - [], - [], - [], - [], - [], - [], - [ - { - type: 'link', - value: - 'https://socket3.wordpress.com/2018/02/03/designing-windows-95s-user-interface/', - }, - ], - [ - { - type: 'link', - value: - 'https://socket3.wordpress.com/2018/02/03/designing-windows-95s-user-interface/', - }, - ], - [ - {type: 'link', value: 'https://foo.com'}, - {type: 'link', value: 'https://bar.com/whatever'}, - {type: 'link', value: 'https://baz.com'}, - ], - [ - {type: 'link', value: 'https://foo.com'}, - {type: 'link', value: 'https://bar.com/whatever'}, - {type: 'link', value: 'https://baz.com'}, - ], - [{type: 'link', value: 'https://foo.com'}], - [{type: 'link', value: 'https://foo.com/thing_(cool)'}], - ] - it('correctly handles a set of text inputs', () => { - for (let i = 0; i < inputs.length; i++) { - const input = inputs[i] - const result = extractEntities(input, knownHandles) - if (!outputs[i].length) { - expect(result).toBeFalsy() - } else if (outputs[i].length && !result) { - expect(result).toBeTruthy() - } else if (result) { - expect(result.length).toBe(outputs[i].length) - for (let j = 0; j < outputs[i].length; j++) { - expect(result[j].type).toEqual(outputs[i][j].type) - if (outputs[i][j].noScheme) { - expect(result[j].value).toEqual(`https://${outputs[i][j].value}`) - } else { - expect(result[j].value).toEqual(outputs[i][j].value) - } - if (outputs[i]?.[j].type === 'mention') { - expect( - input.slice(result[j].index.start, result[j].index.end), - ).toBe(`@${result[j].value}`) - } else { - if (!outputs[i]?.[j].noScheme) { - expect( - input.slice(result[j].index.start, result[j].index.end), - ).toBe(result[j].value) - } else { - expect( - input.slice(result[j].index.start, result[j].index.end), - ).toBe(result[j].value.slice('https://'.length)) - } - } - } - } - } - }) -}) - -describe('detectLinkables', () => { - const inputs = [ - 'no linkable', - '@start middle end', - 'start @middle end', - 'start middle @end', - '@start @middle @end', - '@full123.test-of-chars', - 'not@right', - '@bad!@#$chars', - '@newline1\n@newline2', - 'parenthetical (@handle)', - 'start https://middle.com end', - 'start https://middle.com/foo/bar end', - 'start https://middle.com/foo/bar?baz=bux end', - 'start https://middle.com/foo/bar?baz=bux#hash end', - 'https://start.com/foo/bar?baz=bux#hash middle end', - 'start middle https://end.com/foo/bar?baz=bux#hash', - 'https://newline1.com\nhttps://newline2.com', - 'start middle.com end', - 'start middle.com/foo/bar end', - 'start middle.com/foo/bar?baz=bux end', - 'start middle.com/foo/bar?baz=bux#hash end', - 'start.com/foo/bar?baz=bux#hash middle end', - 'start middle end.com/foo/bar?baz=bux#hash', - 'newline1.com\nnewline2.com', - 'not.. a..url ..here', - 'e.g.', - 'e.g. real.com fake.notreal', - 'something-cool.jpg', - 'website.com.jpg', - 'e.g./foo', - 'website.com.jpg/foo', - 'Classic article https://socket3.wordpress.com/2018/02/03/designing-windows-95s-user-interface/', - 'Classic article https://socket3.wordpress.com/2018/02/03/designing-windows-95s-user-interface/ ', - 'https://foo.com https://bar.com/whatever https://baz.com', - 'punctuation https://foo.com, https://bar.com/whatever; https://baz.com.', - 'parenthentical (https://foo.com)', - 'except for https://foo.com/thing_(cool)', - ] - const outputs = [ - ['no linkable'], - [{link: '@start'}, ' middle end'], - ['start ', {link: '@middle'}, ' end'], - ['start middle ', {link: '@end'}], - [{link: '@start'}, ' ', {link: '@middle'}, ' ', {link: '@end'}], - [{link: '@full123.test-of-chars'}], - ['not@right'], - [{link: '@bad'}, '!@#$chars'], - [{link: '@newline1'}, '\n', {link: '@newline2'}], - ['parenthetical (', {link: '@handle'}, ')'], - ['start ', {link: 'https://middle.com'}, ' end'], - ['start ', {link: 'https://middle.com/foo/bar'}, ' end'], - ['start ', {link: 'https://middle.com/foo/bar?baz=bux'}, ' end'], - ['start ', {link: 'https://middle.com/foo/bar?baz=bux#hash'}, ' end'], - [{link: 'https://start.com/foo/bar?baz=bux#hash'}, ' middle end'], - ['start middle ', {link: 'https://end.com/foo/bar?baz=bux#hash'}], - [{link: 'https://newline1.com'}, '\n', {link: 'https://newline2.com'}], - ['start ', {link: 'middle.com'}, ' end'], - ['start ', {link: 'middle.com/foo/bar'}, ' end'], - ['start ', {link: 'middle.com/foo/bar?baz=bux'}, ' end'], - ['start ', {link: 'middle.com/foo/bar?baz=bux#hash'}, ' end'], - [{link: 'start.com/foo/bar?baz=bux#hash'}, ' middle end'], - ['start middle ', {link: 'end.com/foo/bar?baz=bux#hash'}], - [{link: 'newline1.com'}, '\n', {link: 'newline2.com'}], - ['not.. a..url ..here'], - ['e.g.'], - ['e.g. ', {link: 'real.com'}, ' fake.notreal'], - ['something-cool.jpg'], - ['website.com.jpg'], - ['e.g./foo'], - ['website.com.jpg/foo'], - [ - 'Classic article ', - { - link: 'https://socket3.wordpress.com/2018/02/03/designing-windows-95s-user-interface/', - }, - ], - [ - 'Classic article ', - { - link: 'https://socket3.wordpress.com/2018/02/03/designing-windows-95s-user-interface/', - }, - ' ', - ], - [ - {link: 'https://foo.com'}, - ' ', - {link: 'https://bar.com/whatever'}, - ' ', - {link: 'https://baz.com'}, - ], - [ - 'punctuation ', - {link: 'https://foo.com'}, - ', ', - {link: 'https://bar.com/whatever'}, - '; ', - {link: 'https://baz.com'}, - '.', - ], - ['parenthentical (', {link: 'https://foo.com'}, ')'], - ['except for ', {link: 'https://foo.com/thing_(cool)'}], - ] - it('correctly handles a set of text inputs', () => { - for (let i = 0; i < inputs.length; i++) { - const input = inputs[i] - const output = detectLinkables(input) - expect(output).toEqual(outputs[i]) - } - }) -}) - -describe('extractHtmlMeta', () => { - const inputs = [ - '', - 'nothing', - 'title', - ' aSd!@#AC ', - '\n title\n ', - '', - '', - '', - '', - '', - '', - '', - '', - '', - ] - const outputs = [ - {}, - {}, - {title: 'title'}, - {title: 'aSd!@#AC'}, - {title: 'title'}, - {title: 'meta title'}, - {description: 'meta description'}, - {title: 'og title'}, - {description: 'og description'}, - {image: 'https://ogimage.com/foo.png'}, - {title: 'twitter title'}, - {description: 'twitter description'}, - {image: 'https://twitterimage.com/foo.png'}, - {title: 'meta title'}, - ] - it('correctly handles a set of text inputs', () => { - for (let i = 0; i < inputs.length; i++) { - const input = inputs[i] - const output = extractHtmlMeta(input) - expect(output).toEqual(outputs[i]) - } - }) -}) diff --git a/__tests__/view/screens/Contacts.test.tsx b/__tests__/view/screens/Contacts.test.tsx new file mode 100644 index 000000000..8dc4e56ef --- /dev/null +++ b/__tests__/view/screens/Contacts.test.tsx @@ -0,0 +1,16 @@ +import React from 'react' +import {Contacts} from '../../../src/view/screens/Contacts' +import renderer from 'react-test-renderer' +// import {render} from '../../../../jest/test-utils' + +describe('Contacts', () => { + const mockedProps = { + navIdx: [0, 0] as [number, number], + params: {}, + visible: true, + } + it('renders correctly', () => { + const tree = renderer.create().toJSON() + expect(tree).toMatchSnapshot() + }) +}) diff --git a/__tests__/view/screens/Home.test.tsx b/__tests__/view/screens/Home.test.tsx new file mode 100644 index 000000000..353d4ea50 --- /dev/null +++ b/__tests__/view/screens/Home.test.tsx @@ -0,0 +1,16 @@ +import React from 'react' +import {Home} from '../../../src/view/screens/Home' +import renderer from 'react-test-renderer' +// import {render} from '../../../../jest/test-utils' + +describe('Home', () => { + const mockedProps = { + navIdx: [0, 0] as [number, number], + params: {}, + visible: true, + } + it('renders correctly', () => { + const tree = renderer.create().toJSON() + expect(tree).toMatchSnapshot() + }) +}) diff --git a/__tests__/view/screens/Login.test.tsx b/__tests__/view/screens/Login.test.tsx new file mode 100644 index 000000000..d9faf08a1 --- /dev/null +++ b/__tests__/view/screens/Login.test.tsx @@ -0,0 +1,11 @@ +import React from 'react' +import {Login} from '../../../src/view/screens/Login' +import renderer from 'react-test-renderer' +// import {render} from '../../../../jest/test-utils' + +describe('Login', () => { + it('renders correctly', () => { + const tree = renderer.create().toJSON() + expect(tree).toMatchSnapshot() + }) +}) diff --git a/__tests__/view/screens/NotFound.test.tsx b/__tests__/view/screens/NotFound.test.tsx new file mode 100644 index 000000000..047d309e3 --- /dev/null +++ b/__tests__/view/screens/NotFound.test.tsx @@ -0,0 +1,11 @@ +import React from 'react' +import {NotFound} from '../../../src/view/screens/NotFound' +import renderer from 'react-test-renderer' +// import {render} from '../../../../jest/test-utils' + +describe('NotFound', () => { + it('renders correctly', () => { + const tree = renderer.create().toJSON() + expect(tree).toMatchSnapshot() + }) +}) diff --git a/__tests__/view/screens/Notifications.test.tsx b/__tests__/view/screens/Notifications.test.tsx new file mode 100644 index 000000000..2c5e32cd7 --- /dev/null +++ b/__tests__/view/screens/Notifications.test.tsx @@ -0,0 +1,16 @@ +import React from 'react' +import {Notifications} from '../../../src/view/screens/Notifications' +import renderer from 'react-test-renderer' +// import {render} from '../../../../jest/test-utils' + +describe('Notifications', () => { + const mockedProps = { + navIdx: [0, 0] as [number, number], + params: {}, + visible: true, + } + it('renders correctly', () => { + const tree = renderer.create().toJSON() + expect(tree).toMatchSnapshot() + }) +}) diff --git a/__tests__/view/screens/Onboard.test.tsx b/__tests__/view/screens/Onboard.test.tsx new file mode 100644 index 000000000..69d6f0a72 --- /dev/null +++ b/__tests__/view/screens/Onboard.test.tsx @@ -0,0 +1,11 @@ +import React from 'react' +import {Onboard} from '../../../src/view/screens/Onboard' +import renderer from 'react-test-renderer' +// import {render} from '../../../../jest/test-utils' + +describe('Onboard', () => { + it('renders correctly', () => { + const tree = renderer.create().toJSON() + expect(tree).toMatchSnapshot() + }) +}) diff --git a/__tests__/view/screens/PostDownvotedBy.test.tsx b/__tests__/view/screens/PostDownvotedBy.test.tsx new file mode 100644 index 000000000..8c4119b41 --- /dev/null +++ b/__tests__/view/screens/PostDownvotedBy.test.tsx @@ -0,0 +1,19 @@ +import React from 'react' +import {PostDownvotedBy} from '../../../src/view/screens/PostDownvotedBy' +import renderer from 'react-test-renderer' +// import {render} from '../../../../jest/test-utils' + +describe('PostDownvotedBy', () => { + const mockedProps = { + navIdx: [0, 0] as [number, number], + params: { + name: 'test name', + rkey: '123123123', + }, + visible: true, + } + it('renders correctly', () => { + const tree = renderer.create().toJSON() + expect(tree).toMatchSnapshot() + }) +}) diff --git a/__tests__/view/screens/PostRepostedBy.test.tsx b/__tests__/view/screens/PostRepostedBy.test.tsx new file mode 100644 index 000000000..001224356 --- /dev/null +++ b/__tests__/view/screens/PostRepostedBy.test.tsx @@ -0,0 +1,19 @@ +import React from 'react' +import {PostRepostedBy} from '../../../src/view/screens/PostRepostedBy' +import renderer from 'react-test-renderer' +// import {render} from '../../../../jest/test-utils' + +describe('PostRepostedBy', () => { + const mockedProps = { + navIdx: [0, 0] as [number, number], + params: { + name: 'test name', + rkey: '123123123', + }, + visible: true, + } + it('renders correctly', () => { + const tree = renderer.create().toJSON() + expect(tree).toMatchSnapshot() + }) +}) diff --git a/__tests__/view/screens/PostThread.test.tsx b/__tests__/view/screens/PostThread.test.tsx new file mode 100644 index 000000000..87164ed73 --- /dev/null +++ b/__tests__/view/screens/PostThread.test.tsx @@ -0,0 +1,19 @@ +import React from 'react' +import {PostThread} from '../../../src/view/screens/PostThread' +import renderer from 'react-test-renderer' +// import {render} from '../../../../jest/test-utils' + +describe('PostThread', () => { + const mockedProps = { + navIdx: [0, 0] as [number, number], + params: { + name: 'test name', + rkey: '123123123', + }, + visible: true, + } + it('renders correctly', () => { + const tree = renderer.create().toJSON() + expect(tree).toMatchSnapshot() + }) +}) diff --git a/__tests__/view/screens/PostUpvotedBy.test.tsx b/__tests__/view/screens/PostUpvotedBy.test.tsx new file mode 100644 index 000000000..97912ded6 --- /dev/null +++ b/__tests__/view/screens/PostUpvotedBy.test.tsx @@ -0,0 +1,19 @@ +import React from 'react' +import {PostUpvotedBy} from '../../../src/view/screens/PostUpvotedBy' +import renderer from 'react-test-renderer' +// import {render} from '../../../../jest/test-utils' + +describe('PostUpvotedBy', () => { + const mockedProps = { + navIdx: [0, 0] as [number, number], + params: { + name: 'test name', + rkey: '123123123', + }, + visible: true, + } + it('renders correctly', () => { + const tree = renderer.create().toJSON() + expect(tree).toMatchSnapshot() + }) +}) diff --git a/__tests__/view/screens/Profile.test.tsx b/__tests__/view/screens/Profile.test.tsx new file mode 100644 index 000000000..8912cbfb2 --- /dev/null +++ b/__tests__/view/screens/Profile.test.tsx @@ -0,0 +1,19 @@ +import React from 'react' +import {Profile} from '../../../src/view/screens/Profile' +import renderer from 'react-test-renderer' +// import {render} from '../../../../jest/test-utils' + +describe('Profile', () => { + const mockedProps = { + navIdx: [0, 0] as [number, number], + params: { + name: 'test name', + user: 'test.user', + }, + visible: true, + } + it('renders correctly', () => { + const tree = renderer.create().toJSON() + expect(tree).toMatchSnapshot() + }) +}) diff --git a/__tests__/view/screens/ProfileFollowers.test.tsx b/__tests__/view/screens/ProfileFollowers.test.tsx new file mode 100644 index 000000000..230209aa8 --- /dev/null +++ b/__tests__/view/screens/ProfileFollowers.test.tsx @@ -0,0 +1,18 @@ +import React from 'react' +import {ProfileFollowers} from '../../../src/view/screens/ProfileFollowers' +import renderer from 'react-test-renderer' +// import {render} from '../../../../jest/test-utils' + +describe('ProfileFollowers', () => { + const mockedProps = { + navIdx: [0, 0] as [number, number], + params: { + name: 'test name', + }, + visible: true, + } + it('renders correctly', () => { + const tree = renderer.create().toJSON() + expect(tree).toMatchSnapshot() + }) +}) diff --git a/__tests__/view/screens/ProfileFollows.test.tsx b/__tests__/view/screens/ProfileFollows.test.tsx new file mode 100644 index 000000000..e4571b5cb --- /dev/null +++ b/__tests__/view/screens/ProfileFollows.test.tsx @@ -0,0 +1,18 @@ +import React from 'react' +import {ProfileFollows} from '../../../src/view/screens/ProfileFollows' +import renderer from 'react-test-renderer' +// import {render} from '../../../../jest/test-utils' + +describe('ProfileFollows', () => { + const mockedProps = { + navIdx: [0, 0] as [number, number], + params: { + name: 'test name', + }, + visible: true, + } + it('renders correctly', () => { + const tree = renderer.create().toJSON() + expect(tree).toMatchSnapshot() + }) +}) diff --git a/__tests__/view/screens/ProfileMembers.test.tsx b/__tests__/view/screens/ProfileMembers.test.tsx new file mode 100644 index 000000000..a33e03a1f --- /dev/null +++ b/__tests__/view/screens/ProfileMembers.test.tsx @@ -0,0 +1,18 @@ +import React from 'react' +import {ProfileMembers} from '../../../src/view/screens/ProfileMembers' +import renderer from 'react-test-renderer' +// import {render} from '../../../../jest/test-utils' + +describe('ProfileMembers', () => { + const mockedProps = { + navIdx: [0, 0] as [number, number], + params: { + name: 'test name', + }, + visible: true, + } + it('renders correctly', () => { + const tree = renderer.create().toJSON() + expect(tree).toMatchSnapshot() + }) +}) diff --git a/__tests__/view/screens/Search.test.tsx b/__tests__/view/screens/Search.test.tsx new file mode 100644 index 000000000..477e077af --- /dev/null +++ b/__tests__/view/screens/Search.test.tsx @@ -0,0 +1,18 @@ +import React from 'react' +import {Search} from '../../../src/view/screens/Search' +import renderer from 'react-test-renderer' +// import {render} from '../../../../jest/test-utils' + +describe('Search', () => { + const mockedProps = { + navIdx: [0, 0] as [number, number], + params: { + name: 'test name', + }, + visible: true, + } + it('renders correctly', () => { + const tree = renderer.create().toJSON() + expect(tree).toMatchSnapshot() + }) +}) diff --git a/__tests__/view/screens/Settings.test.tsx b/__tests__/view/screens/Settings.test.tsx new file mode 100644 index 000000000..475639ebb --- /dev/null +++ b/__tests__/view/screens/Settings.test.tsx @@ -0,0 +1,16 @@ +import React from 'react' +import {Settings} from '../../../src/view/screens/Settings' +import renderer from 'react-test-renderer' +// import {render} from '../../../../jest/test-utils' + +describe('Settings', () => { + const mockedProps = { + navIdx: [0, 0] as [number, number], + params: {}, + visible: true, + } + it('renders correctly', () => { + const tree = renderer.create().toJSON() + expect(tree).toMatchSnapshot() + }) +}) diff --git a/__tests__/view/screens/__snapshots__/Contacts.test.tsx.snap b/__tests__/view/screens/__snapshots__/Contacts.test.tsx.snap new file mode 100644 index 000000000..61a857088 --- /dev/null +++ b/__tests__/view/screens/__snapshots__/Contacts.test.tsx.snap @@ -0,0 +1,205 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Contacts renders correctly 1`] = ` + + + + Contacts + + + + + < + icon="magnifying-glass" + size={16} + style={ + Object { + "color": "#645454", + "marginRight": 8, + } + } + /> + + + + + + + + All + + + + + Following + + + + + Scenes + + + + +`; diff --git a/__tests__/view/screens/__snapshots__/Home.test.tsx.snap b/__tests__/view/screens/__snapshots__/Home.test.tsx.snap new file mode 100644 index 000000000..4d2c51097 --- /dev/null +++ b/__tests__/view/screens/__snapshots__/Home.test.tsx.snap @@ -0,0 +1,594 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Home renders correctly 1`] = ` + + + + + + + + + + + + + + + + + + Bluesky + + + Private Beta + + + + < + icon="plus" + size={18} + /> + + + + + + + + + + < + icon="signal" + size={18} + style={ + Array [ + Object { + "color": "#000000", + }, + ] + } + /> + < + icon="x" + size={12} + style={ + Object { + "backgroundColor": "#ffffff", + "color": "#d1106f", + "left": -4, + "position": "relative", + "top": 6, + } + } + /> + + + + + + + + + + + + + + + + + + + + What's up? + + + + + Post + + + + + +`; diff --git a/__tests__/view/screens/__snapshots__/Login.test.tsx.snap b/__tests__/view/screens/__snapshots__/Login.test.tsx.snap new file mode 100644 index 000000000..b86d8656e --- /dev/null +++ b/__tests__/view/screens/__snapshots__/Login.test.tsx.snap @@ -0,0 +1,371 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Login renders correctly 1`] = ` + + + + + + + + + + + + + + + + + + Bluesky + + + [ private beta ] + + + + + + Create a new account + + + + + + + + + + + or + + + + + Sign in + + + + +`; diff --git a/__tests__/view/screens/__snapshots__/NotFound.test.tsx.snap b/__tests__/view/screens/__snapshots__/NotFound.test.tsx.snap new file mode 100644 index 000000000..a9365718c --- /dev/null +++ b/__tests__/view/screens/__snapshots__/NotFound.test.tsx.snap @@ -0,0 +1,431 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`NotFound renders correctly 1`] = ` + + + + + + + + + + + + + + + + + + Page not found + + + + < + icon="plus" + size={18} + /> + + + + + + + + + + < + icon="signal" + size={18} + style={ + Array [ + Object { + "color": "#000000", + }, + ] + } + /> + < + icon="x" + size={12} + style={ + Object { + "backgroundColor": "#ffffff", + "color": "#d1106f", + "left": -4, + "position": "relative", + "top": 6, + } + } + /> + + + + + Page not found + + + + + Home + + + + + +`; diff --git a/__tests__/view/screens/__snapshots__/Notifications.test.tsx.snap b/__tests__/view/screens/__snapshots__/Notifications.test.tsx.snap new file mode 100644 index 000000000..6c1eef57e --- /dev/null +++ b/__tests__/view/screens/__snapshots__/Notifications.test.tsx.snap @@ -0,0 +1,378 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Notifications renders correctly 1`] = ` + + + + + + + + + + + + + + + + + + Notifications + + + + < + icon="plus" + size={18} + /> + + + + + + + + + + < + icon="signal" + size={18} + style={ + Array [ + Object { + "color": "#000000", + }, + ] + } + /> + < + icon="x" + size={12} + style={ + Object { + "backgroundColor": "#ffffff", + "color": "#d1106f", + "left": -4, + "position": "relative", + "top": 6, + } + } + /> + + + + +`; diff --git a/__tests__/view/screens/__snapshots__/Onboard.test.tsx.snap b/__tests__/view/screens/__snapshots__/Onboard.test.tsx.snap new file mode 100644 index 000000000..5422fb0de --- /dev/null +++ b/__tests__/view/screens/__snapshots__/Onboard.test.tsx.snap @@ -0,0 +1,388 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Onboard renders correctly 1`] = ` + + + + + + + + + Welcome to + + Bluesky + + + + Let's do a quick tour through the new features. + + + + + + + + + + + + + ° + + + + + ° + + + + + + + + + Skip + + + + + + Next + + + + + +`; diff --git a/__tests__/view/screens/__snapshots__/PostDownvotedBy.test.tsx.snap b/__tests__/view/screens/__snapshots__/PostDownvotedBy.test.tsx.snap new file mode 100644 index 000000000..aa41d7fb2 --- /dev/null +++ b/__tests__/view/screens/__snapshots__/PostDownvotedBy.test.tsx.snap @@ -0,0 +1,368 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`PostDownvotedBy renders correctly 1`] = ` + + + + + + + + + + + + + + + + + + Downvoted by + + + + < + icon="plus" + size={18} + /> + + + + + + + + + + < + icon="signal" + size={18} + style={ + Array [ + Object { + "color": "#000000", + }, + ] + } + /> + < + icon="x" + size={12} + style={ + Object { + "backgroundColor": "#ffffff", + "color": "#d1106f", + "left": -4, + "position": "relative", + "top": 6, + } + } + /> + + + + + + +`; diff --git a/__tests__/view/screens/__snapshots__/PostRepostedBy.test.tsx.snap b/__tests__/view/screens/__snapshots__/PostRepostedBy.test.tsx.snap new file mode 100644 index 000000000..f6af5ec5a --- /dev/null +++ b/__tests__/view/screens/__snapshots__/PostRepostedBy.test.tsx.snap @@ -0,0 +1,368 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`PostRepostedBy renders correctly 1`] = ` + + + + + + + + + + + + + + + + + + Reposted by + + + + < + icon="plus" + size={18} + /> + + + + + + + + + + < + icon="signal" + size={18} + style={ + Array [ + Object { + "color": "#000000", + }, + ] + } + /> + < + icon="x" + size={12} + style={ + Object { + "backgroundColor": "#ffffff", + "color": "#d1106f", + "left": -4, + "position": "relative", + "top": 6, + } + } + /> + + + + + + +`; diff --git a/__tests__/view/screens/__snapshots__/PostThread.test.tsx.snap b/__tests__/view/screens/__snapshots__/PostThread.test.tsx.snap new file mode 100644 index 000000000..abb36931c --- /dev/null +++ b/__tests__/view/screens/__snapshots__/PostThread.test.tsx.snap @@ -0,0 +1,437 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`PostThread renders correctly 1`] = ` + + + + + + + + + + + + + + + + + + Post + + + by test name + + + + < + icon="plus" + size={18} + /> + + + + + + + + + + < + icon="signal" + size={18} + style={ + Array [ + Object { + "color": "#000000", + }, + ] + } + /> + < + icon="x" + size={12} + style={ + Object { + "backgroundColor": "#ffffff", + "color": "#d1106f", + "left": -4, + "position": "relative", + "top": 6, + } + } + /> + + + + + } + refreshing={false} + removeClippedSubviews={false} + renderItem={[Function]} + scrollEventThrottle={50} + stickyHeaderIndices={Array []} + style={ + Object { + "flex": 1, + } + } + viewabilityConfigCallbackPairs={Array []} + > + + + + + +`; diff --git a/__tests__/view/screens/__snapshots__/PostUpvotedBy.test.tsx.snap b/__tests__/view/screens/__snapshots__/PostUpvotedBy.test.tsx.snap new file mode 100644 index 000000000..a7bb6aae5 --- /dev/null +++ b/__tests__/view/screens/__snapshots__/PostUpvotedBy.test.tsx.snap @@ -0,0 +1,368 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`PostUpvotedBy renders correctly 1`] = ` + + + + + + + + + + + + + + + + + + Upvoted by + + + + < + icon="plus" + size={18} + /> + + + + + + + + + + < + icon="signal" + size={18} + style={ + Array [ + Object { + "color": "#000000", + }, + ] + } + /> + < + icon="x" + size={12} + style={ + Object { + "backgroundColor": "#ffffff", + "color": "#d1106f", + "left": -4, + "position": "relative", + "top": 6, + } + } + /> + + + + + + +`; diff --git a/__tests__/view/screens/__snapshots__/Profile.test.tsx.snap b/__tests__/view/screens/__snapshots__/Profile.test.tsx.snap new file mode 100644 index 000000000..e9640b6ee --- /dev/null +++ b/__tests__/view/screens/__snapshots__/Profile.test.tsx.snap @@ -0,0 +1,513 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Profile renders correctly 1`] = ` + + + + + + + + + + + + + + + + + + test name + + + + < + icon="plus" + size={18} + /> + + + + + + + + + + < + icon="signal" + size={18} + style={ + Array [ + Object { + "color": "#000000", + }, + ] + } + /> + < + icon="x" + size={12} + style={ + Object { + "backgroundColor": "#ffffff", + "color": "#d1106f", + "left": -4, + "position": "relative", + "top": 6, + } + } + /> + + + + + + + + + + + + + + + + + + + + + + + + + +`; diff --git a/__tests__/view/screens/__snapshots__/ProfileFollowers.test.tsx.snap b/__tests__/view/screens/__snapshots__/ProfileFollowers.test.tsx.snap new file mode 100644 index 000000000..237773b42 --- /dev/null +++ b/__tests__/view/screens/__snapshots__/ProfileFollowers.test.tsx.snap @@ -0,0 +1,386 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`ProfileFollowers renders correctly 1`] = ` + + + + + + + + + + + + + + + + + + Followers + + + of test name + + + + < + icon="plus" + size={18} + /> + + + + + + + + + + < + icon="signal" + size={18} + style={ + Array [ + Object { + "color": "#000000", + }, + ] + } + /> + < + icon="x" + size={12} + style={ + Object { + "backgroundColor": "#ffffff", + "color": "#d1106f", + "left": -4, + "position": "relative", + "top": 6, + } + } + /> + + + + + + +`; diff --git a/__tests__/view/screens/__snapshots__/ProfileFollows.test.tsx.snap b/__tests__/view/screens/__snapshots__/ProfileFollows.test.tsx.snap new file mode 100644 index 000000000..cba1a7343 --- /dev/null +++ b/__tests__/view/screens/__snapshots__/ProfileFollows.test.tsx.snap @@ -0,0 +1,386 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`ProfileFollows renders correctly 1`] = ` + + + + + + + + + + + + + + + + + + Followed + + + by test name + + + + < + icon="plus" + size={18} + /> + + + + + + + + + + < + icon="signal" + size={18} + style={ + Array [ + Object { + "color": "#000000", + }, + ] + } + /> + < + icon="x" + size={12} + style={ + Object { + "backgroundColor": "#ffffff", + "color": "#d1106f", + "left": -4, + "position": "relative", + "top": 6, + } + } + /> + + + + + + +`; diff --git a/__tests__/view/screens/__snapshots__/ProfileMembers.test.tsx.snap b/__tests__/view/screens/__snapshots__/ProfileMembers.test.tsx.snap new file mode 100644 index 000000000..e36a4b080 --- /dev/null +++ b/__tests__/view/screens/__snapshots__/ProfileMembers.test.tsx.snap @@ -0,0 +1,386 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`ProfileMembers renders correctly 1`] = ` + + + + + + + + + + + + + + + + + + Members + + + of test name + + + + < + icon="plus" + size={18} + /> + + + + + + + + + + < + icon="signal" + size={18} + style={ + Array [ + Object { + "color": "#000000", + }, + ] + } + /> + < + icon="x" + size={12} + style={ + Object { + "backgroundColor": "#ffffff", + "color": "#d1106f", + "left": -4, + "position": "relative", + "top": 6, + } + } + /> + + + + + + +`; diff --git a/__tests__/view/screens/__snapshots__/Search.test.tsx.snap b/__tests__/view/screens/__snapshots__/Search.test.tsx.snap new file mode 100644 index 000000000..130552076 --- /dev/null +++ b/__tests__/view/screens/__snapshots__/Search.test.tsx.snap @@ -0,0 +1,514 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Search renders correctly 1`] = ` + + + + + + + + + + + + + + + + + + Search + + + + < + icon="plus" + size={18} + /> + + + + + + + + + + < + icon="signal" + size={18} + style={ + Array [ + Object { + "color": "#000000", + }, + ] + } + /> + < + icon="x" + size={12} + style={ + Object { + "backgroundColor": "#ffffff", + "color": "#d1106f", + "left": -4, + "position": "relative", + "top": 6, + } + } + /> + + + + + + + + + + + + + + + + + + + + +`; diff --git a/__tests__/view/screens/__snapshots__/Settings.test.tsx.snap b/__tests__/view/screens/__snapshots__/Settings.test.tsx.snap new file mode 100644 index 000000000..77402da21 --- /dev/null +++ b/__tests__/view/screens/__snapshots__/Settings.test.tsx.snap @@ -0,0 +1,631 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Settings renders correctly 1`] = ` + + + + + + + + + + + + + + + + + + Settings + + + + < + icon="plus" + size={18} + /> + + + + + + + + + + < + icon="signal" + size={18} + style={ + Array [ + Object { + "color": "#000000", + }, + ] + } + /> + < + icon="x" + size={12} + style={ + Object { + "backgroundColor": "#ffffff", + "color": "#d1106f", + "left": -4, + "position": "relative", + "top": 6, + } + } + /> + + + + + + Signed in as + + + + + Sign out + + + + + + + + + + + + + + + + + + + + + + @ + + + + + + + +`; diff --git a/__tests__/view/shell/mobile/Composer.test.tsx b/__tests__/view/shell/mobile/Composer.test.tsx new file mode 100644 index 000000000..7b84cfd88 --- /dev/null +++ b/__tests__/view/shell/mobile/Composer.test.tsx @@ -0,0 +1,23 @@ +import React from 'react' +import {Composer} from '../../../../src/view/shell/mobile/Composer' +import renderer from 'react-test-renderer' +// import {render} from '../../../../jest/test-utils' + +describe('Composer', () => { + const mockedProps = { + active: true, + winHeight: 844, + replyTo: { + author: {avatar: undefined, displayName: 'Alice', handle: 'alice.test'}, + cid: 'bafyreieucrv36ylxrut4dr4jj264q2jj2vt2vfvhjfchgw3vua4gksvzia', + text: 'Captain, maybe we ought to turn on the searchlights now. No… that’s just what they’ll be expecting us to do.', + uri: 'at://did:plc:v3xz273ea2dzjpu2szsjzfue/app.bsky.feed.post/3jkcir3fhqv2u', + }, + onPost: jest.fn(), + onClose: jest.fn(), + } + it('renders correctly', () => { + const tree = renderer.create().toJSON() + expect(tree).toMatchSnapshot() + }) +}) diff --git a/__tests__/view/shell/mobile/Menu.test.tsx b/__tests__/view/shell/mobile/Menu.test.tsx new file mode 100644 index 000000000..5305bd77a --- /dev/null +++ b/__tests__/view/shell/mobile/Menu.test.tsx @@ -0,0 +1,15 @@ +import React from 'react' +import {Menu} from '../../../../src/view/shell/mobile/Menu' +import renderer from 'react-test-renderer' +// import {render} from '../../../../jest/test-utils' + +describe('Menu', () => { + const mockedProps = { + visible: true, + onClose: jest.fn(), + } + it('renders correctly', () => { + const tree = renderer.create().toJSON() + expect(tree).toMatchSnapshot() + }) +}) diff --git a/__tests__/view/shell/mobile/TabsSelector.test.tsx b/__tests__/view/shell/mobile/TabsSelector.test.tsx new file mode 100644 index 000000000..7908f442e --- /dev/null +++ b/__tests__/view/shell/mobile/TabsSelector.test.tsx @@ -0,0 +1,17 @@ +import React from 'react' +import {Animated} from 'react-native' +import renderer from 'react-test-renderer' +import {TabsSelector} from '../../../../src/view/shell/mobile/TabsSelector' +// import {render} from '../../../../jest/test-utils' + +describe('TabsSelector', () => { + const mockedProps = { + active: true, + tabMenuInterp: new Animated.Value(0), + onClose: jest.fn(), + } + it('renders correctly', () => { + const tree = renderer.create().toJSON() + expect(tree).toMatchSnapshot() + }) +}) diff --git a/__tests__/view/shell/mobile/__snapshots__/Composer.test.tsx.snap b/__tests__/view/shell/mobile/__snapshots__/Composer.test.tsx.snap new file mode 100644 index 000000000..6ced9871b --- /dev/null +++ b/__tests__/view/shell/mobile/__snapshots__/Composer.test.tsx.snap @@ -0,0 +1,659 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Composer renders correctly 1`] = ` + + + + + + + Cancel + + + + + + + Reply + + + + + + + + + + + + + + + + + + + + + Alice + + + Captain, maybe we ought to turn on the searchlights now. No… that’s just what they’ll be expecting us to do. + + + + + + + + + + + + + + + + + + + + + + < + icon={ + Array [ + "far", + "image", + ] + } + size={24} + style={ + Object { + "color": "#0085ff", + } + } + /> + + + + 256 + + + + + + + + + + + + + + + + +`; diff --git a/__tests__/view/shell/mobile/__snapshots__/Menu.test.tsx.snap b/__tests__/view/shell/mobile/__snapshots__/Menu.test.tsx.snap new file mode 100644 index 000000000..78c34b967 --- /dev/null +++ b/__tests__/view/shell/mobile/__snapshots__/Menu.test.tsx.snap @@ -0,0 +1,837 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Menu renders correctly 1`] = ` + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Search + + + + + + + + + + + + + Home + + + + + + + + + + + + + Notifications + + + + + + Scenes + + + + + + + + + + + + + Create a scene + + + + + + + + + + + + + Settings + + + + + + Build version + ( + ) + + + +`; diff --git a/__tests__/view/shell/mobile/__snapshots__/TabsSelector.test.tsx.snap b/__tests__/view/shell/mobile/__snapshots__/TabsSelector.test.tsx.snap new file mode 100644 index 000000000..03e0636de --- /dev/null +++ b/__tests__/view/shell/mobile/__snapshots__/TabsSelector.test.tsx.snap @@ -0,0 +1,651 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`TabsSelector renders correctly 1`] = ` + + + + + + + < + icon="share" + size={16} + /> + + + Share + + + + + < + icon={ + Array [ + "far", + "clone", + ] + } + size={16} + /> + + + Clone tab + + + + + < + icon="plus" + size={16} + /> + + + New tab + + + + + + + + + + + + + + + + + + + + + + < + icon="house" + size={20} + /> + + + / + + + + < + icon="x" + size={14} + style={ + Object { + "color": "#655", + } + } + /> + + + + + + + + + + + + + + + + + + + + < + icon="bell" + size={20} + /> + + + /notifications + + + + < + icon="x" + size={14} + style={ + Object { + "color": "#655", + } + } + /> + + + + + + + + + + +`; diff --git a/__tests__/view/shell/mobile/__snapshots__/index.test.tsx.snap b/__tests__/view/shell/mobile/__snapshots__/index.test.tsx.snap new file mode 100644 index 000000000..793668b73 --- /dev/null +++ b/__tests__/view/shell/mobile/__snapshots__/index.test.tsx.snap @@ -0,0 +1,421 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`MobileShell renders correctly 1`] = ` + + + + + + + + + + + + + + + + + + + + Bluesky + + + [ private beta ] + + + + + + Create a new account + + + + + + + + + + + or + + + + + Sign in + + + + + + + + + +`; diff --git a/__tests__/view/shell/mobile/index.test.tsx b/__tests__/view/shell/mobile/index.test.tsx new file mode 100644 index 000000000..96f161260 --- /dev/null +++ b/__tests__/view/shell/mobile/index.test.tsx @@ -0,0 +1,18 @@ +import React from 'react' +import {MobileShell} from '../../../../src/view/shell/mobile' +import renderer from 'react-test-renderer' +import {SafeAreaProvider} from 'react-native-safe-area-context' +// import {render} from '../../../../jest/test-utils' + +describe('MobileShell', () => { + it('renders correctly', () => { + const tree = renderer + .create( + + + , + ) + .toJSON() + expect(tree).toMatchSnapshot() + }) +}) -- cgit 1.4.1