forked from e-mission/e-mission-phone
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
138 changed files
with
12,778 additions
and
9,251 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 |
---|---|---|
@@ -1,23 +1,21 @@ | ||
export const mockFileSystem = () => { | ||
window['resolveLocalFileSystemURL'] = function (parentDir, handleFS) { | ||
const fs = { | ||
filesystem: | ||
{ | ||
root: | ||
{ | ||
filesystem: { | ||
root: { | ||
getFile: (path, options, onSuccess) => { | ||
let fileEntry = { | ||
file: (handleFile) => { | ||
let file = new File(["this is a mock"], "loggerDB"); | ||
let file = new File(['this is a mock'], 'loggerDB'); | ||
handleFile(file); | ||
} | ||
} | ||
}, | ||
}; | ||
onSuccess(fileEntry); | ||
} | ||
} | ||
} | ||
} | ||
console.log("in mock, fs is ", fs, " get File is ", fs.filesystem.root.getFile); | ||
}, | ||
}, | ||
}, | ||
}; | ||
console.log('in mock, fs is ', fs, ' get File is ', fs.filesystem.root.getFile); | ||
handleFS(fs); | ||
} | ||
} | ||
}; | ||
}; |
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
export const mockLogger = () => { | ||
window['Logger'] = { log: console.log }; | ||
} | ||
}; |
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 |
---|---|---|
@@ -1,30 +1,23 @@ | ||
/** | ||
* @jest-environment jsdom | ||
*/ | ||
import React from 'react' | ||
import {render, fireEvent, waitFor, screen} from '@testing-library/react-native' | ||
import LoadMoreButton from '../js/diary/list/LoadMoreButton' | ||
import React from 'react'; | ||
import { render, fireEvent, waitFor, screen } from '@testing-library/react-native'; | ||
import LoadMoreButton from '../js/diary/list/LoadMoreButton'; | ||
|
||
|
||
describe("LoadMoreButton", () => { | ||
it("renders correctly", async () => { | ||
render( | ||
<LoadMoreButton onPressFn={() => {}}>{}</LoadMoreButton> | ||
); | ||
describe('LoadMoreButton', () => { | ||
it('renders correctly', async () => { | ||
render(<LoadMoreButton onPressFn={() => {}}>{}</LoadMoreButton>); | ||
await waitFor(() => { | ||
expect(screen.getByTestId("load-button")).toBeTruthy(); | ||
expect(screen.getByTestId('load-button')).toBeTruthy(); | ||
}); | ||
}); | ||
|
||
it("calls onPressFn when clicked", () => { | ||
it('calls onPressFn when clicked', () => { | ||
const mockFn = jest.fn(); | ||
const { getByTestId } = render( | ||
<LoadMoreButton onPressFn={mockFn}>{}</LoadMoreButton> | ||
); | ||
const loadButton = getByTestId("load-button"); | ||
const { getByTestId } = render(<LoadMoreButton onPressFn={mockFn}>{}</LoadMoreButton>); | ||
const loadButton = getByTestId('load-button'); | ||
fireEvent.press(loadButton); | ||
expect(mockFn).toHaveBeenCalled(); | ||
}); | ||
}); | ||
|
||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,38 @@ | ||
import { onLaunchCustomURL } from '../js/splash/customURL'; | ||
|
||
describe('onLaunchCustomURL', () => { | ||
let mockHandler; | ||
let mockHandler; | ||
|
||
beforeEach(() => { | ||
// create a new mock handler before each test case. | ||
mockHandler = jest.fn(); | ||
}); | ||
beforeEach(() => { | ||
// create a new mock handler before each test case. | ||
mockHandler = jest.fn(); | ||
}); | ||
|
||
it('tests valid url 1 - should call handler callback with valid URL and the handler should be called with correct parameters', () => { | ||
const validURL = 'emission://login_token?token=nrelop_dev-emulator-program'; | ||
const expectedURL = 'login_token?token=nrelop_dev-emulator-program'; | ||
const expectedComponents = { route: 'login_token', token: 'nrelop_dev-emulator-program' }; | ||
onLaunchCustomURL(validURL, mockHandler); | ||
expect(mockHandler).toHaveBeenCalledWith(expectedURL, expectedComponents); | ||
}); | ||
it('tests valid url 1 - should call handler callback with valid URL and the handler should be called with correct parameters', () => { | ||
const validURL = 'emission://login_token?token=nrelop_dev-emulator-program'; | ||
const expectedURL = 'login_token?token=nrelop_dev-emulator-program'; | ||
const expectedComponents = { route: 'login_token', token: 'nrelop_dev-emulator-program' }; | ||
onLaunchCustomURL(validURL, mockHandler); | ||
expect(mockHandler).toHaveBeenCalledWith(expectedURL, expectedComponents); | ||
}); | ||
|
||
it('tests valid url 2 - should call handler callback with valid URL and the handler should be called with correct parameters', () => { | ||
const validURL = 'emission://test?param1=first¶m2=second'; | ||
const expectedURL = 'test?param1=first¶m2=second'; | ||
const expectedComponents = { route: 'test', param1: 'first', param2: 'second' }; | ||
onLaunchCustomURL(validURL, mockHandler); | ||
expect(mockHandler).toHaveBeenCalledWith(expectedURL, expectedComponents); | ||
}); | ||
it('tests valid url 2 - should call handler callback with valid URL and the handler should be called with correct parameters', () => { | ||
const validURL = 'emission://test?param1=first¶m2=second'; | ||
const expectedURL = 'test?param1=first¶m2=second'; | ||
const expectedComponents = { route: 'test', param1: 'first', param2: 'second' }; | ||
onLaunchCustomURL(validURL, mockHandler); | ||
expect(mockHandler).toHaveBeenCalledWith(expectedURL, expectedComponents); | ||
}); | ||
|
||
it('test invalid url 1 - should not call handler callback with invalid URL', () => { | ||
const invalidURL = 'invalid_url'; | ||
onLaunchCustomURL(invalidURL, mockHandler); | ||
expect(mockHandler).not.toHaveBeenCalled(); | ||
}); | ||
it('test invalid url 1 - should not call handler callback with invalid URL', () => { | ||
const invalidURL = 'invalid_url'; | ||
onLaunchCustomURL(invalidURL, mockHandler); | ||
expect(mockHandler).not.toHaveBeenCalled(); | ||
}); | ||
|
||
it('tests invalid url 2 - should not call handler callback with invalid URL', () => { | ||
const invalidURL = ''; | ||
onLaunchCustomURL(invalidURL, mockHandler); | ||
expect(mockHandler).not.toHaveBeenCalled(); | ||
}); | ||
}) | ||
it('tests invalid url 2 - should not call handler callback with invalid URL', () => { | ||
const invalidURL = ''; | ||
onLaunchCustomURL(invalidURL, mockHandler); | ||
expect(mockHandler).not.toHaveBeenCalled(); | ||
}); | ||
}); |
Oops, something went wrong.