-
Notifications
You must be signed in to change notification settings - Fork 353
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
remove Connect device as it's not in the scope of add account + add i…
…ntegration tests on device selection
- Loading branch information
1 parent
d90b722
commit f8d65d6
Showing
9 changed files
with
113 additions
and
233 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
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
91 changes: 91 additions & 0 deletions
91
...rc/newArch/features/DeviceSelection/__integrations__/deviceSelection.integration.test.tsx
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,91 @@ | ||
import * as React from "react"; | ||
import { render, screen } from "@tests/test-renderer"; | ||
import DeviceSelectionNavigator from "../Navigator"; | ||
import { useRoute, useNavigation } from "@react-navigation/native"; | ||
import { discoverDevices } from "@ledgerhq/live-common/hw/index"; | ||
import { DeviceModelId } from "@ledgerhq/types-devices"; | ||
import { of } from "rxjs"; | ||
|
||
const MockUseRoute = useRoute as jest.Mock; | ||
const mockNavigate = jest.fn(); | ||
const mockDiscoverDevices = discoverDevices as jest.Mock; | ||
|
||
(useNavigation as jest.Mock).mockReturnValue({ | ||
navigate: mockNavigate, | ||
addListener: jest.fn(), | ||
}); | ||
|
||
jest.mock("@ledgerhq/live-common/deposit/index", () => ({ | ||
useGroupedCurrenciesByProvider: jest.fn(), | ||
})); | ||
|
||
jest.mock("@react-navigation/native", () => ({ | ||
...jest.requireActual("@react-navigation/native"), | ||
useRoute: jest.fn(), | ||
useNavigation: jest.fn(), | ||
})); | ||
|
||
jest.mock("@ledgerhq/live-common/hw/index", () => ({ | ||
...jest.requireActual("@ledgerhq/live-common/hw/index"), | ||
discoverDevices: jest.fn(), | ||
})); | ||
|
||
describe("Device Selection feature integration test", () => { | ||
beforeAll(() => { | ||
MockUseRoute.mockReturnValue({ | ||
params: { | ||
context: "addAccounts", | ||
currency: { | ||
type: "CryptoCurrency", | ||
id: "bitcoin", | ||
ticker: "BTC", | ||
name: "Bitcoin", | ||
family: "bitcoin", | ||
color: "#ffae35", | ||
decimals: 8, | ||
managerAppName: "Bitcoin", | ||
}, | ||
}, | ||
}); | ||
}); | ||
it("should render a device connection screen when no device is installed", () => { | ||
mockDiscoverDevices.mockReturnValue(of({})); | ||
render(<DeviceSelectionNavigator />); | ||
|
||
const screenTitle = screen.getByText(/Connect device/i); | ||
const listHeader = screen.getByText(/Devices/i); | ||
const stepIndicator = screen.getByText(/Step 2 of 3/i); | ||
const addDevuceCTA = screen.getByText(/Add a Ledger/i); | ||
const bottomText = screen.getByText(/Need a new Ledger?/i); | ||
const buyNowCTA = screen.getByText(/Buy now?/i); | ||
|
||
[listHeader, screenTitle, stepIndicator, addDevuceCTA, bottomText, buyNowCTA].forEach( | ||
element => { | ||
expect(element).toBeOnTheScreen(); | ||
}, | ||
); | ||
}); | ||
|
||
it("should render a device selection screen when a device is installed", () => { | ||
mockDiscoverDevices.mockReturnValue( | ||
of({ | ||
type: "add", | ||
id: "usb|1", | ||
name: "Ledger Stax device", | ||
deviceModel: { id: DeviceModelId.stax }, | ||
wired: true, | ||
}), | ||
); | ||
render(<DeviceSelectionNavigator />); | ||
const deviceCTA = screen.getByTestId("device-item-usb|1"); | ||
const notConnectedText = screen.getByText(/connected/i); | ||
const addDevuceCTA = screen.queryByText(/Add a Ledger/i); | ||
const bottomText = screen.getByText(/Need a new Ledger?/i); | ||
const buyNowCTA = screen.getByText(/Buy now?/i); | ||
|
||
[deviceCTA, notConnectedText, bottomText, buyNowCTA].forEach(element => { | ||
expect(element).toBeOnTheScreen(); | ||
}); | ||
expect(addDevuceCTA).not.toBeOnTheScreen(); | ||
}); | ||
}); |
179 changes: 0 additions & 179 deletions
179
apps/ledger-live-mobile/src/newArch/features/DeviceSelection/screens/ConnectDevice/index.tsx
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.