mirror of https://gitlab.com/m3f_usm/SmartStopAPK
feat: some refactor + clean code + tests
parent
0a75bacccb
commit
91d1e0c5c0
|
@ -9,4 +9,5 @@ module.exports = {
|
|||
'react/jsx-uses-react': 'off',
|
||||
'react/react-in-jsx-scope': 'off',
|
||||
},
|
||||
ignorePatterns: ['coverage'],
|
||||
};
|
||||
|
|
72
README.md
72
README.md
|
@ -1,69 +1,31 @@
|
|||
This is a new [**React Native**](https://reactnative.dev) project, bootstrapped using [`@react-native-community/cli`](https://github.com/react-native-community/cli).
|
||||
|
||||
# Getting Started
|
||||
|
||||
>**Note**: Make sure you have completed the [React Native - Environment Setup](https://reactnative.dev/docs/environment-setup) instructions till "Creating a new application" step, before proceeding.
|
||||
> **Note**: Make sure you have completed the [React Native - Environment Setup](https://reactnative.dev/docs/environment-setup) instructions till "Creating a new application" step, before proceeding.
|
||||
|
||||
## Step 1: Start the Metro Server
|
||||
|
||||
First, you will need to start **Metro**, the JavaScript _bundler_ that ships _with_ React Native.
|
||||
|
||||
To start Metro, run the following command from the _root_ of your React Native project:
|
||||
## Step 1: Install dependencies
|
||||
|
||||
```bash
|
||||
# using npm
|
||||
npm start
|
||||
|
||||
# OR using Yarn
|
||||
yarn start
|
||||
yarn install
|
||||
```
|
||||
|
||||
## Step 2: Start your Application
|
||||
|
||||
Let Metro Bundler run in its _own_ terminal. Open a _new_ terminal from the _root_ of your React Native project. Run the following command to start your _Android_ or _iOS_ app:
|
||||
|
||||
### For Android
|
||||
|
||||
```bash
|
||||
# using npm
|
||||
npm run android
|
||||
|
||||
# OR using Yarn
|
||||
yarn android
|
||||
```
|
||||
|
||||
### For iOS
|
||||
|
||||
```bash
|
||||
# using npm
|
||||
npm run ios
|
||||
|
||||
# OR using Yarn
|
||||
yarn ios
|
||||
```
|
||||
|
||||
If everything is set up _correctly_, you should see your new app running in your _Android Emulator_ or _iOS Simulator_ shortly provided you have set up your emulator/simulator correctly.
|
||||
If everything is set up _correctly_, you should see your new app running in your Android Emulator or iOS Simulator shortly provided you have set up your emulator/simulator correctly.
|
||||
|
||||
This is one way to run your app — you can also run it directly from within Android Studio and Xcode respectively.
|
||||
|
||||
## Step 3: Modifying your App
|
||||
|
||||
Now that you have successfully run the app, let's modify it.
|
||||
|
||||
1. Open `App.tsx` in your text editor of choice and edit some lines.
|
||||
2. For **Android**: Press the <kbd>R</kbd> key twice or select **"Reload"** from the **Developer Menu** (<kbd>Ctrl</kbd> + <kbd>M</kbd> (on Window and Linux) or <kbd>Cmd ⌘</kbd> + <kbd>M</kbd> (on macOS)) to see your changes!
|
||||
|
||||
For **iOS**: Hit <kbd>Cmd ⌘</kbd> + <kbd>R</kbd> in your iOS Simulator to reload the app and see your changes!
|
||||
|
||||
## Congratulations! :tada:
|
||||
|
||||
You've successfully run and modified your React Native App. :partying_face:
|
||||
|
||||
### Now what?
|
||||
|
||||
- If you want to add this new React Native code to an existing application, check out the [Integration guide](https://reactnative.dev/docs/integration-with-existing-apps).
|
||||
- If you're curious to learn more about React Native, check out the [Introduction to React Native](https://reactnative.dev/docs/getting-started).
|
||||
|
||||
# Troubleshooting
|
||||
|
||||
If you can't get this to work, see the [Troubleshooting](https://reactnative.dev/docs/troubleshooting) page.
|
||||
|
@ -77,3 +39,29 @@ To learn more about React Native, take a look at the following resources:
|
|||
- [Learn the Basics](https://reactnative.dev/docs/getting-started) - a **guided tour** of the React Native **basics**.
|
||||
- [Blog](https://reactnative.dev/blog) - read the latest official React Native **Blog** posts.
|
||||
- [`@facebook/react-native`](https://github.com/facebook/react-native) - the Open Source; GitHub **repository** for React Native.
|
||||
|
||||
## Utility scripts
|
||||
|
||||
### Start metro server
|
||||
|
||||
```bash
|
||||
yarn start
|
||||
```
|
||||
|
||||
### Linting code
|
||||
|
||||
```bash
|
||||
yarn lint
|
||||
```
|
||||
|
||||
### Run tests
|
||||
|
||||
```bash
|
||||
yarn test
|
||||
```
|
||||
|
||||
### Create a release apk
|
||||
|
||||
```bash
|
||||
yarn build:apk:release
|
||||
```
|
||||
|
|
|
@ -1,11 +1,19 @@
|
|||
export const fetchAndActivate = jest.fn();
|
||||
export const setConfigSettings = jest.fn();
|
||||
export const setDefaults = jest.fn();
|
||||
export const getValue = jest.fn();
|
||||
export const getAll = jest.fn();
|
||||
export const getString = jest.fn();
|
||||
export const getNumber = jest.fn();
|
||||
|
||||
const remoteConfig = () => ({
|
||||
fetchAndActivate: jest.fn(() => Promise.resolve(true)),
|
||||
setConfigSettings: jest.fn(),
|
||||
setDefaults: jest.fn(),
|
||||
getValue: jest.fn(),
|
||||
getAll: jest.fn(),
|
||||
getString: jest.fn(),
|
||||
getNumber: jest.fn(),
|
||||
fetchAndActivate,
|
||||
setConfigSettings,
|
||||
setDefaults,
|
||||
getValue,
|
||||
getAll,
|
||||
getString,
|
||||
getNumber,
|
||||
});
|
||||
|
||||
export default remoteConfig;
|
||||
|
|
|
@ -6,5 +6,7 @@ const esModules = [
|
|||
|
||||
export default {
|
||||
preset: 'react-native',
|
||||
collectCoverage: true,
|
||||
collectCoverageFrom: ['src/**/*.{ts,tsx}'],
|
||||
transformIgnorePatterns: [`node_modules/(?!${esModules})`],
|
||||
};
|
||||
|
|
|
@ -4,11 +4,12 @@
|
|||
"private": true,
|
||||
"scripts": {
|
||||
"prepare": "husky install",
|
||||
"start": "react-native start",
|
||||
"android": "react-native run-android",
|
||||
"ios": "react-native run-ios",
|
||||
"lint": "eslint .",
|
||||
"start": "react-native start",
|
||||
"test": "jest"
|
||||
"test": "jest",
|
||||
"build:apk:release": "cd android;./gradlew assembleRelease;open app/build/outputs/apk/release;cd .."
|
||||
},
|
||||
"dependencies": {
|
||||
"@react-native-firebase/app": "^18.7.3",
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
const COLUMNS = 3;
|
||||
const ROWS = 7;
|
||||
const BUSES_BY_PAGE = COLUMNS * ROWS;
|
||||
|
||||
export {COLUMNS, ROWS, BUSES_BY_PAGE};
|
|
@ -3,7 +3,7 @@ import Arrival from './Arrival';
|
|||
interface LineDetail {
|
||||
lineNumber: string;
|
||||
description: string;
|
||||
locomotionType: number;
|
||||
locomotionType: string;
|
||||
backgroundColor: string;
|
||||
letterColor: string;
|
||||
lineMessage: string;
|
||||
|
|
|
@ -3,7 +3,6 @@ import LineDetail from '../repositories/LineDetail';
|
|||
import {getHours, getMinutes, getSeconds} from '../../utils/DateUtils';
|
||||
import Arrival from '../repositories/Arrival';
|
||||
|
||||
// TODO: Change to a better name or split ?
|
||||
class BusStopInfoService {
|
||||
private lines: LineDetail[];
|
||||
|
||||
|
@ -31,11 +30,12 @@ class BusStopInfoService {
|
|||
}
|
||||
|
||||
getNextArraival(lineNumber: string): Arrival {
|
||||
const currentTime = moment();
|
||||
const currentTime = moment().local();
|
||||
|
||||
const nextArraival = this.getLinesByNumber(lineNumber).arrivals.find(
|
||||
arrival => {
|
||||
const compareTime = moment();
|
||||
const compareTime = moment().local();
|
||||
|
||||
compareTime.set('hour', getHours(arrival.estimatedGPS));
|
||||
compareTime.set('minute', getMinutes(arrival.estimatedGPS));
|
||||
compareTime.set('second', getSeconds(arrival.estimatedGPS));
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import axios from 'axios';
|
||||
import AuthResponse from '../models/AuthResponse';
|
||||
import AuthRequest from '../models/AuthRequest';
|
||||
import {LOGIN_METHOD} from '../../consts/urls';
|
||||
|
||||
class AuthAPI {
|
||||
private baseURL: string;
|
||||
|
@ -18,10 +19,13 @@ class AuthAPI {
|
|||
throw new Error('password is required');
|
||||
}
|
||||
|
||||
const {data} = await axios.post<AuthResponse>(`${this.baseURL}/api/auth/`, {
|
||||
username,
|
||||
password,
|
||||
});
|
||||
const {data} = await axios.post<AuthResponse>(
|
||||
`${this.baseURL}${LOGIN_METHOD}`,
|
||||
{
|
||||
username,
|
||||
password,
|
||||
},
|
||||
);
|
||||
|
||||
return data;
|
||||
}
|
||||
|
|
|
@ -2,7 +2,8 @@ import axios from 'axios';
|
|||
import DeviceRequest from '../models/DeviceRequest';
|
||||
import {GetInfoDeviceResponse} from '../models/GetInfoDeviceResponse';
|
||||
import WhoamiResponse from '../models/WhoamiResponse';
|
||||
import responseDevicesMock from './response-devices-mock.json';
|
||||
import {INFO_DEVICE_METHOD, WHOAMI_METHOD} from '../../consts/urls';
|
||||
// import responseDevicesMock from './response-devices-mock.json';
|
||||
|
||||
const KEYAUTORIZACION = 'token';
|
||||
|
||||
|
@ -22,7 +23,7 @@ class DevicesAPI {
|
|||
throw new Error('deviceId is required');
|
||||
}
|
||||
const {data} = await axios.post<WhoamiResponse>(
|
||||
`${this.baseURL}/api/dispositivos/whoami/`,
|
||||
`${this.baseURL}${WHOAMI_METHOD}`,
|
||||
{
|
||||
whoami: {idDispositivo: deviceId, KeyAuthorizacion: KEYAUTORIZACION},
|
||||
},
|
||||
|
@ -49,7 +50,7 @@ class DevicesAPI {
|
|||
}
|
||||
|
||||
const {data} = await axios.post<GetInfoDeviceResponse>(
|
||||
`${this.baseURL}/api/dispositivos/getInfoDevice/`,
|
||||
`${this.baseURL}${INFO_DEVICE_METHOD}`,
|
||||
{
|
||||
GetInfoDevice: {
|
||||
idDispositivo: deviceId,
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,6 +1,5 @@
|
|||
const BASE_URL = 'https://transporte.hz.kursor.cl';
|
||||
const LOGIN_METHOD = '/api/auth/';
|
||||
const WHOAMI_METHOD = '/api/dispositivos/whoami/';
|
||||
const INFO_DEVICE_METHOD = '/api/dispositivos/getInfoDevice/';
|
||||
|
||||
export {BASE_URL, LOGIN_METHOD, WHOAMI_METHOD, INFO_DEVICE_METHOD};
|
||||
export {LOGIN_METHOD, WHOAMI_METHOD, INFO_DEVICE_METHOD};
|
||||
|
|
|
@ -0,0 +1,508 @@
|
|||
{
|
||||
"lineDetails": [
|
||||
{
|
||||
"lineNumber": "Vía Láctea 10K - Leonera",
|
||||
"description": "10K",
|
||||
"locomotionType": null,
|
||||
"backgroundColor": "0071ca",
|
||||
"letterColor": "ffffff",
|
||||
"arrivals": [
|
||||
{"planned": null, "estimatedGPS": "01:16:25", "distanceGPS": null},
|
||||
{"planned": null, "estimatedGPS": "01:28:58", "distanceGPS": null}
|
||||
]
|
||||
},
|
||||
{
|
||||
"lineNumber": "Vía Láctea 10L - Los Bloques",
|
||||
"description": "10L",
|
||||
"locomotionType": null,
|
||||
"backgroundColor": "4e0963",
|
||||
"letterColor": "ffffff",
|
||||
"arrivals": [
|
||||
{"planned": null, "estimatedGPS": "00:56:01", "distanceGPS": null},
|
||||
{"planned": null, "estimatedGPS": "01:10:21", "distanceGPS": null},
|
||||
{"planned": null, "estimatedGPS": "01:30:40", "distanceGPS": null},
|
||||
{"planned": null, "estimatedGPS": "01:36:28", "distanceGPS": null}
|
||||
]
|
||||
},
|
||||
{
|
||||
"lineNumber": "Vía Láctea 10M - Los Bloques",
|
||||
"description": "10M",
|
||||
"locomotionType": null,
|
||||
"backgroundColor": "ad0101",
|
||||
"letterColor": "ffffff",
|
||||
"arrivals": [
|
||||
{"planned": null, "estimatedGPS": "01:20:34", "distanceGPS": null}
|
||||
]
|
||||
},
|
||||
{
|
||||
"lineNumber": "Vía Láctea 10N - Los Bloques",
|
||||
"description": "10N",
|
||||
"locomotionType": null,
|
||||
"backgroundColor": "b10086",
|
||||
"letterColor": "ffffff",
|
||||
"arrivals": [
|
||||
{"planned": null, "estimatedGPS": "00:36:30", "distanceGPS": null},
|
||||
{"planned": null, "estimatedGPS": "00:37:46", "distanceGPS": null},
|
||||
{"planned": null, "estimatedGPS": "00:43:33", "distanceGPS": null},
|
||||
{"planned": null, "estimatedGPS": "01:13:25", "distanceGPS": null},
|
||||
{"planned": null, "estimatedGPS": "01:30:33", "distanceGPS": null},
|
||||
{"planned": null, "estimatedGPS": "01:37:31", "distanceGPS": null},
|
||||
{"planned": null, "estimatedGPS": "01:39:04", "distanceGPS": null}
|
||||
]
|
||||
},
|
||||
{
|
||||
"lineNumber": "Vía Láctea 10O - Pobl. Porvenir",
|
||||
"description": "10O",
|
||||
"locomotionType": null,
|
||||
"backgroundColor": "0d7215",
|
||||
"letterColor": "ffffff",
|
||||
"arrivals": [
|
||||
{"planned": null, "estimatedGPS": "00:45:13", "distanceGPS": null},
|
||||
{"planned": null, "estimatedGPS": "01:17:44", "distanceGPS": null},
|
||||
{"planned": null, "estimatedGPS": "01:33:02", "distanceGPS": null}
|
||||
]
|
||||
},
|
||||
{
|
||||
"lineNumber": "Vía Láctea 10P - Leonera",
|
||||
"description": "10P",
|
||||
"locomotionType": null,
|
||||
"backgroundColor": "0071ca",
|
||||
"letterColor": "ffffff",
|
||||
"arrivals": [
|
||||
{"planned": null, "estimatedGPS": "00:38:33", "distanceGPS": null},
|
||||
{"planned": null, "estimatedGPS": "01:27:15", "distanceGPS": null}
|
||||
]
|
||||
},
|
||||
{
|
||||
"lineNumber": "Vía Futuro 11Q - Los Bloques",
|
||||
"description": "11Q",
|
||||
"locomotionType": null,
|
||||
"backgroundColor": "ad0101",
|
||||
"letterColor": "ffffff",
|
||||
"arrivals": [
|
||||
{"planned": null, "estimatedGPS": "01:06:21", "distanceGPS": null},
|
||||
{"planned": null, "estimatedGPS": "01:11:44", "distanceGPS": null},
|
||||
{"planned": null, "estimatedGPS": "01:22:11", "distanceGPS": null}
|
||||
]
|
||||
},
|
||||
{
|
||||
"lineNumber": "Vía Futuro 11R - Porvenir",
|
||||
"description": "11R",
|
||||
"locomotionType": null,
|
||||
"backgroundColor": "b10086",
|
||||
"letterColor": "ffffff",
|
||||
"arrivals": [
|
||||
{"planned": null, "estimatedGPS": "00:55:10", "distanceGPS": null},
|
||||
{"planned": null, "estimatedGPS": "01:10:58", "distanceGPS": null},
|
||||
{"planned": null, "estimatedGPS": "01:18:11", "distanceGPS": null},
|
||||
{"planned": null, "estimatedGPS": "01:30:42", "distanceGPS": null}
|
||||
]
|
||||
},
|
||||
{
|
||||
"lineNumber": "Vía Siglo XXI 13S - Leonera",
|
||||
"description": "13S",
|
||||
"locomotionType": null,
|
||||
"backgroundColor": "ce5504",
|
||||
"letterColor": "ffffff",
|
||||
"arrivals": [
|
||||
{"planned": null, "estimatedGPS": "00:38:24", "distanceGPS": null},
|
||||
{"planned": null, "estimatedGPS": "00:38:34", "distanceGPS": null},
|
||||
{"planned": null, "estimatedGPS": "00:39:30", "distanceGPS": null},
|
||||
{"planned": null, "estimatedGPS": "00:40:11", "distanceGPS": null},
|
||||
{"planned": null, "estimatedGPS": "00:47:29", "distanceGPS": null},
|
||||
{"planned": null, "estimatedGPS": "00:56:02", "distanceGPS": null},
|
||||
{"planned": null, "estimatedGPS": "01:02:20", "distanceGPS": null},
|
||||
{"planned": null, "estimatedGPS": "01:18:02", "distanceGPS": null},
|
||||
{"planned": null, "estimatedGPS": "01:19:13", "distanceGPS": null},
|
||||
{"planned": null, "estimatedGPS": "01:21:56", "distanceGPS": null}
|
||||
]
|
||||
},
|
||||
{
|
||||
"lineNumber": "Chiguayante Sur 14T - Coquimbo",
|
||||
"description": "14T",
|
||||
"locomotionType": null,
|
||||
"backgroundColor": "ce5504",
|
||||
"letterColor": "ffffff",
|
||||
"arrivals": [
|
||||
{"planned": null, "estimatedGPS": "00:38:25", "distanceGPS": null},
|
||||
{"planned": null, "estimatedGPS": "00:55:26", "distanceGPS": null},
|
||||
{"planned": null, "estimatedGPS": "01:09:13", "distanceGPS": null},
|
||||
{"planned": null, "estimatedGPS": "01:25:39", "distanceGPS": null}
|
||||
]
|
||||
},
|
||||
{
|
||||
"lineNumber": "Chiguayante Sur 14U - Los Altos",
|
||||
"description": "14U",
|
||||
"locomotionType": null,
|
||||
"backgroundColor": "cc9b00",
|
||||
"letterColor": "ffffff",
|
||||
"arrivals": [
|
||||
{"planned": null, "estimatedGPS": "00:36:31", "distanceGPS": null},
|
||||
{"planned": null, "estimatedGPS": "00:37:14", "distanceGPS": null},
|
||||
{"planned": null, "estimatedGPS": "00:39:44", "distanceGPS": null},
|
||||
{"planned": null, "estimatedGPS": "00:40:00", "distanceGPS": null}
|
||||
]
|
||||
},
|
||||
{
|
||||
"lineNumber": "Vía Universo 16K - Leonera",
|
||||
"description": "16K",
|
||||
"locomotionType": null,
|
||||
"backgroundColor": "ce5504",
|
||||
"letterColor": "ffffff",
|
||||
"arrivals": [
|
||||
{"planned": null, "estimatedGPS": "00:38:51", "distanceGPS": null},
|
||||
{"planned": null, "estimatedGPS": "01:02:49", "distanceGPS": null},
|
||||
{"planned": null, "estimatedGPS": "01:10:52", "distanceGPS": null},
|
||||
{"planned": null, "estimatedGPS": "01:18:39", "distanceGPS": null},
|
||||
{"planned": null, "estimatedGPS": "01:32:02", "distanceGPS": null}
|
||||
]
|
||||
},
|
||||
{
|
||||
"lineNumber": "Vía Universo 16V - Leonera",
|
||||
"description": "16V",
|
||||
"locomotionType": null,
|
||||
"backgroundColor": "ad0101",
|
||||
"letterColor": "ffffff",
|
||||
"arrivals": [
|
||||
{"planned": null, "estimatedGPS": "00:48:11", "distanceGPS": null},
|
||||
{"planned": null, "estimatedGPS": "01:17:45", "distanceGPS": null}
|
||||
]
|
||||
},
|
||||
{
|
||||
"lineNumber": "Expresos Chiguayante 17C - Leonera",
|
||||
"description": "17C",
|
||||
"locomotionType": null,
|
||||
"backgroundColor": "0071ca",
|
||||
"letterColor": "ffffff",
|
||||
"arrivals": [
|
||||
{"planned": null, "estimatedGPS": "00:43:30", "distanceGPS": null},
|
||||
{"planned": null, "estimatedGPS": "01:13:28", "distanceGPS": null}
|
||||
]
|
||||
},
|
||||
{
|
||||
"lineNumber": "Expresos Chiguayante 17W - Leonera",
|
||||
"description": "17W",
|
||||
"locomotionType": null,
|
||||
"backgroundColor": "0d7215",
|
||||
"letterColor": "ffffff",
|
||||
"arrivals": [
|
||||
{"planned": null, "estimatedGPS": "00:36:23", "distanceGPS": null},
|
||||
{"planned": null, "estimatedGPS": "00:47:02", "distanceGPS": null},
|
||||
{"planned": null, "estimatedGPS": "00:51:20", "distanceGPS": null},
|
||||
{"planned": null, "estimatedGPS": "01:18:00", "distanceGPS": null},
|
||||
{"planned": null, "estimatedGPS": "01:18:39", "distanceGPS": null},
|
||||
{"planned": null, "estimatedGPS": "01:19:37", "distanceGPS": null}
|
||||
]
|
||||
},
|
||||
{
|
||||
"lineNumber": "Expresos Chiguayante 17X - Leonera",
|
||||
"description": "17X",
|
||||
"locomotionType": null,
|
||||
"backgroundColor": "ce5504",
|
||||
"letterColor": "ffffff",
|
||||
"arrivals": [
|
||||
{"planned": null, "estimatedGPS": "00:35:52", "distanceGPS": null},
|
||||
{"planned": null, "estimatedGPS": "00:50:21", "distanceGPS": null},
|
||||
{"planned": null, "estimatedGPS": "00:52:25", "distanceGPS": null},
|
||||
{"planned": null, "estimatedGPS": "00:52:31", "distanceGPS": null},
|
||||
{"planned": null, "estimatedGPS": "00:56:31", "distanceGPS": null},
|
||||
{"planned": null, "estimatedGPS": "01:02:00", "distanceGPS": null}
|
||||
]
|
||||
},
|
||||
{
|
||||
"lineNumber": "Buses Palomares 18Y - Hualqui",
|
||||
"description": "18Y",
|
||||
"locomotionType": null,
|
||||
"backgroundColor": "0071ca",
|
||||
"letterColor": "ffffff",
|
||||
"arrivals": [
|
||||
{"planned": null, "estimatedGPS": "00:51:14", "distanceGPS": null}
|
||||
]
|
||||
},
|
||||
{
|
||||
"lineNumber": "Nueva Llacolén 20A - Boca Sur",
|
||||
"description": "23A",
|
||||
"locomotionType": null,
|
||||
"backgroundColor": "0071ca",
|
||||
"letterColor": "ffffff",
|
||||
"arrivals": [
|
||||
{"planned": null, "estimatedGPS": "00:40:00", "distanceGPS": null},
|
||||
{"planned": null, "estimatedGPS": "01:00:25", "distanceGPS": null},
|
||||
{"planned": null, "estimatedGPS": "01:20:51", "distanceGPS": null}
|
||||
]
|
||||
},
|
||||
{
|
||||
"lineNumber": "Nueva Llacolén 20M - San Pedro Costa",
|
||||
"description": "23M",
|
||||
"locomotionType": null,
|
||||
"backgroundColor": "b10086",
|
||||
"letterColor": "ffffff",
|
||||
"arrivals": [
|
||||
{"planned": null, "estimatedGPS": "00:45:32", "distanceGPS": null},
|
||||
{"planned": null, "estimatedGPS": "01:08:55", "distanceGPS": null},
|
||||
{"planned": null, "estimatedGPS": "01:14:25", "distanceGPS": null}
|
||||
]
|
||||
},
|
||||
{
|
||||
"lineNumber": "Riviera Biobío 21B - Candelaria",
|
||||
"description": "00B",
|
||||
"locomotionType": null,
|
||||
"backgroundColor": "ce5504",
|
||||
"letterColor": "ffffff",
|
||||
"arrivals": [
|
||||
{"planned": null, "estimatedGPS": "00:35:51", "distanceGPS": null},
|
||||
{"planned": null, "estimatedGPS": "00:40:49", "distanceGPS": null},
|
||||
{"planned": null, "estimatedGPS": "00:43:01", "distanceGPS": null}
|
||||
]
|
||||
},
|
||||
{
|
||||
"lineNumber": "Buses San Pedro 22D - Michaihue",
|
||||
"description": "22D",
|
||||
"locomotionType": null,
|
||||
"backgroundColor": "b38800",
|
||||
"letterColor": "ffffff",
|
||||
"arrivals": [
|
||||
{"planned": null, "estimatedGPS": "00:49:24", "distanceGPS": null},
|
||||
{"planned": null, "estimatedGPS": "00:56:26", "distanceGPS": null}
|
||||
]
|
||||
},
|
||||
{
|
||||
"lineNumber": "Ruta Las Playas 30Q - Higueras",
|
||||
"description": "30Q",
|
||||
"locomotionType": null,
|
||||
"backgroundColor": "0d7215",
|
||||
"letterColor": "ffffff",
|
||||
"arrivals": [
|
||||
{"planned": null, "estimatedGPS": "00:38:58", "distanceGPS": null},
|
||||
{"planned": null, "estimatedGPS": "00:52:56", "distanceGPS": null},
|
||||
{"planned": null, "estimatedGPS": "01:17:48", "distanceGPS": null},
|
||||
{"planned": null, "estimatedGPS": "01:27:27", "distanceGPS": null}
|
||||
]
|
||||
},
|
||||
{
|
||||
"lineNumber": "Ruta Las Playas 30R - Higueras",
|
||||
"description": "30R",
|
||||
"locomotionType": null,
|
||||
"backgroundColor": "049684",
|
||||
"letterColor": "ffffff",
|
||||
"arrivals": [
|
||||
{"planned": null, "estimatedGPS": "00:38:37", "distanceGPS": null},
|
||||
{"planned": null, "estimatedGPS": "00:45:06", "distanceGPS": null},
|
||||
{"planned": null, "estimatedGPS": "01:03:46", "distanceGPS": null},
|
||||
{"planned": null, "estimatedGPS": "01:23:56", "distanceGPS": null}
|
||||
]
|
||||
},
|
||||
{
|
||||
"lineNumber": "Ruta del Mar 31D - Lobos Viejos",
|
||||
"description": "31D",
|
||||
"locomotionType": null,
|
||||
"backgroundColor": "ad0101",
|
||||
"letterColor": "ffffff",
|
||||
"arrivals": [
|
||||
{"planned": null, "estimatedGPS": "00:39:41", "distanceGPS": null},
|
||||
{"planned": null, "estimatedGPS": "00:44:07", "distanceGPS": null},
|
||||
{"planned": null, "estimatedGPS": "01:20:41", "distanceGPS": null}
|
||||
]
|
||||
},
|
||||
{
|
||||
"lineNumber": "Ruta del Mar 32E - Lobos Viejos",
|
||||
"description": "32E",
|
||||
"locomotionType": null,
|
||||
"backgroundColor": "b10086",
|
||||
"letterColor": "ffffff",
|
||||
"arrivals": [
|
||||
{"planned": null, "estimatedGPS": "00:41:14", "distanceGPS": null},
|
||||
{"planned": null, "estimatedGPS": "01:17:51", "distanceGPS": null},
|
||||
{"planned": null, "estimatedGPS": "01:36:01", "distanceGPS": null}
|
||||
]
|
||||
},
|
||||
{
|
||||
"lineNumber": "Ruta del Mar 32J - Lobos Viejos",
|
||||
"description": "32J",
|
||||
"locomotionType": null,
|
||||
"backgroundColor": "598200",
|
||||
"letterColor": "ffffff",
|
||||
"arrivals": [
|
||||
{"planned": null, "estimatedGPS": "00:36:34", "distanceGPS": null},
|
||||
{"planned": null, "estimatedGPS": "00:58:20", "distanceGPS": null},
|
||||
{"planned": null, "estimatedGPS": "01:29:34", "distanceGPS": null}
|
||||
]
|
||||
},
|
||||
{
|
||||
"lineNumber": "Las Golondrinas 40G - Candelaria",
|
||||
"description": "40G",
|
||||
"locomotionType": null,
|
||||
"backgroundColor": "ad0101",
|
||||
"letterColor": "ffffff",
|
||||
"arrivals": [
|
||||
{"planned": null, "estimatedGPS": "00:36:34", "distanceGPS": null},
|
||||
{"planned": null, "estimatedGPS": "00:42:28", "distanceGPS": null},
|
||||
{"planned": null, "estimatedGPS": "01:06:34", "distanceGPS": null},
|
||||
{"planned": null, "estimatedGPS": "01:19:39", "distanceGPS": null}
|
||||
]
|
||||
},
|
||||
{
|
||||
"lineNumber": "Buses Hualpencillo 42F - Concepción",
|
||||
"description": "42F",
|
||||
"locomotionType": null,
|
||||
"backgroundColor": "ce5504",
|
||||
"letterColor": "ffffff",
|
||||
"arrivals": [
|
||||
{"planned": null, "estimatedGPS": "00:38:15", "distanceGPS": null},
|
||||
{"planned": null, "estimatedGPS": "00:51:04", "distanceGPS": null},
|
||||
{"planned": null, "estimatedGPS": "01:09:43", "distanceGPS": null},
|
||||
{"planned": null, "estimatedGPS": "01:27:19", "distanceGPS": null}
|
||||
]
|
||||
},
|
||||
{
|
||||
"lineNumber": "Base Naval 56O - Pta. Los Leones",
|
||||
"description": "56O",
|
||||
"locomotionType": null,
|
||||
"backgroundColor": "0071ca",
|
||||
"letterColor": "ffffff",
|
||||
"arrivals": [
|
||||
{"planned": null, "estimatedGPS": "00:38:06", "distanceGPS": null},
|
||||
{"planned": null, "estimatedGPS": "00:38:53", "distanceGPS": null},
|
||||
{"planned": null, "estimatedGPS": "00:53:02", "distanceGPS": null}
|
||||
]
|
||||
},
|
||||
{
|
||||
"lineNumber": "Denavi Sur 57Y - Cosmito",
|
||||
"description": "57Y",
|
||||
"locomotionType": null,
|
||||
"backgroundColor": "ce5504",
|
||||
"letterColor": "ffffff",
|
||||
"arrivals": [
|
||||
{"planned": null, "estimatedGPS": "00:56:20", "distanceGPS": null},
|
||||
{"planned": null, "estimatedGPS": "01:13:07", "distanceGPS": null}
|
||||
]
|
||||
},
|
||||
{
|
||||
"lineNumber": "Mi Expreso 62M - San Vicente",
|
||||
"description": "62M",
|
||||
"locomotionType": null,
|
||||
"backgroundColor": "0071ca",
|
||||
"letterColor": "ffffff",
|
||||
"arrivals": [
|
||||
{"planned": null, "estimatedGPS": "00:38:39", "distanceGPS": null},
|
||||
{"planned": null, "estimatedGPS": "00:43:41", "distanceGPS": null}
|
||||
]
|
||||
},
|
||||
{
|
||||
"lineNumber": "Las Bahías 70I - Centinela",
|
||||
"description": "70I",
|
||||
"locomotionType": null,
|
||||
"backgroundColor": "613FA6",
|
||||
"letterColor": "ffffff",
|
||||
"arrivals": [
|
||||
{"planned": null, "estimatedGPS": "00:36:42", "distanceGPS": null},
|
||||
{"planned": null, "estimatedGPS": "00:50:09", "distanceGPS": null},
|
||||
{"planned": null, "estimatedGPS": "00:52:19", "distanceGPS": null},
|
||||
{"planned": null, "estimatedGPS": "00:53:14", "distanceGPS": null},
|
||||
{"planned": null, "estimatedGPS": "01:14:24", "distanceGPS": null}
|
||||
]
|
||||
},
|
||||
{
|
||||
"lineNumber": "Las Bahías 70J - Los Copihues",
|
||||
"description": "70J",
|
||||
"locomotionType": null,
|
||||
"backgroundColor": "b38800",
|
||||
"letterColor": "ffffff",
|
||||
"arrivals": [
|
||||
{"planned": null, "estimatedGPS": "00:44:12", "distanceGPS": null},
|
||||
{"planned": null, "estimatedGPS": "00:50:43", "distanceGPS": null},
|
||||
{"planned": null, "estimatedGPS": "00:52:14", "distanceGPS": null}
|
||||
]
|
||||
},
|
||||
{
|
||||
"lineNumber": "Las Bahías 70K - Los Copihues",
|
||||
"description": "70K",
|
||||
"locomotionType": null,
|
||||
"backgroundColor": "0d7215",
|
||||
"letterColor": "ffffff",
|
||||
"arrivals": [
|
||||
{"planned": null, "estimatedGPS": "00:56:25", "distanceGPS": null}
|
||||
]
|
||||
},
|
||||
{
|
||||
"lineNumber": "Pedro de Valdivia 72K - Lonco",
|
||||
"description": "72K",
|
||||
"locomotionType": null,
|
||||
"backgroundColor": "0071ca",
|
||||
"letterColor": "ffffff",
|
||||
"arrivals": [
|
||||
{"planned": null, "estimatedGPS": "00:38:25", "distanceGPS": null},
|
||||
{"planned": null, "estimatedGPS": "00:56:36", "distanceGPS": null}
|
||||
]
|
||||
},
|
||||
{
|
||||
"lineNumber": "Las Galaxias 80H - Hualqui",
|
||||
"description": "80H",
|
||||
"locomotionType": null,
|
||||
"backgroundColor": "0071ca",
|
||||
"letterColor": "ffffff",
|
||||
"arrivals": [
|
||||
{"planned": null, "estimatedGPS": "00:39:25", "distanceGPS": null},
|
||||
{"planned": null, "estimatedGPS": "00:49:45", "distanceGPS": null},
|
||||
{"planned": null, "estimatedGPS": "01:11:22", "distanceGPS": null},
|
||||
{"planned": null, "estimatedGPS": "01:26:46", "distanceGPS": null}
|
||||
]
|
||||
},
|
||||
{
|
||||
"lineNumber": "Las Galaxias 80Q - Hualqui",
|
||||
"description": "80Q",
|
||||
"locomotionType": null,
|
||||
"backgroundColor": "ce5504",
|
||||
"letterColor": "ffffff",
|
||||
"arrivals": [
|
||||
{"planned": null, "estimatedGPS": "00:38:06", "distanceGPS": null},
|
||||
{"planned": null, "estimatedGPS": "00:40:37", "distanceGPS": null},
|
||||
{"planned": null, "estimatedGPS": "00:59:11", "distanceGPS": null},
|
||||
{"planned": null, "estimatedGPS": "01:17:13", "distanceGPS": null}
|
||||
]
|
||||
},
|
||||
{
|
||||
"lineNumber": "Las Galaxias 80Z - Valle Piedra",
|
||||
"description": "80Z",
|
||||
"locomotionType": null,
|
||||
"backgroundColor": "0d7215",
|
||||
"letterColor": "ffffff",
|
||||
"arrivals": [
|
||||
{"planned": null, "estimatedGPS": "00:40:04", "distanceGPS": null},
|
||||
{"planned": null, "estimatedGPS": "00:41:04", "distanceGPS": null},
|
||||
{"planned": null, "estimatedGPS": "00:49:17", "distanceGPS": null},
|
||||
{"planned": null, "estimatedGPS": "00:54:41", "distanceGPS": null},
|
||||
{"planned": null, "estimatedGPS": "01:08:28", "distanceGPS": null},
|
||||
{"planned": null, "estimatedGPS": "01:10:49", "distanceGPS": null},
|
||||
{"planned": null, "estimatedGPS": "01:23:49", "distanceGPS": null},
|
||||
{"planned": null, "estimatedGPS": "01:30:39", "distanceGPS": null}
|
||||
]
|
||||
},
|
||||
{
|
||||
"lineNumber": "Nueva Sol Yet 90X - Parque Central",
|
||||
"description": "90X",
|
||||
"locomotionType": null,
|
||||
"backgroundColor": "ad0101",
|
||||
"letterColor": "ffffff",
|
||||
"arrivals": [
|
||||
{"planned": null, "estimatedGPS": "00:40:10", "distanceGPS": null},
|
||||
{"planned": null, "estimatedGPS": "00:45:13", "distanceGPS": null},
|
||||
{"planned": null, "estimatedGPS": "00:49:49", "distanceGPS": null},
|
||||
{"planned": null, "estimatedGPS": "00:53:22", "distanceGPS": null}
|
||||
]
|
||||
},
|
||||
{
|
||||
"lineNumber": "Biobús B02 - Centro Concepción",
|
||||
"description": "B02",
|
||||
"locomotionType": null,
|
||||
"backgroundColor": "0d7215",
|
||||
"letterColor": "ffffff",
|
||||
"arrivals": [
|
||||
{"planned": null, "estimatedGPS": "00:43:11", "distanceGPS": null},
|
||||
{"planned": null, "estimatedGPS": "01:02:10", "distanceGPS": null},
|
||||
{"planned": null, "estimatedGPS": "01:15:00", "distanceGPS": null}
|
||||
]
|
||||
}
|
||||
],
|
||||
"stopMessage": "No considerar, uso futuro"
|
||||
}
|
|
@ -1,10 +1,20 @@
|
|||
import {renderHook, waitFor} from '@testing-library/react-native';
|
||||
import {act, renderHook, waitFor} from '@testing-library/react-native';
|
||||
import useDevices from '../useDevices';
|
||||
import AuthRepositoryImpl from '../../repositories/AuthRepositoryImpl';
|
||||
import DevicesRepositoryImpl from '../../repositories/DevicesRepositoryImpl';
|
||||
import mockResponse from '../__mocks__/mockResponse.json';
|
||||
import {getNumber} from '../../../../__mocks__/@react-native-firebase/remote-config';
|
||||
|
||||
jest.useFakeTimers();
|
||||
describe('useDevices tests', () => {
|
||||
beforeEach(() => {
|
||||
jest.clearAllMocks();
|
||||
jest.useFakeTimers();
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
jest.useRealTimers();
|
||||
});
|
||||
|
||||
beforeAll(() => {
|
||||
jest.spyOn(AuthRepositoryImpl.prototype, 'auth').mockResolvedValue('token');
|
||||
jest
|
||||
|
@ -74,6 +84,8 @@ describe('useDevices tests', () => {
|
|||
stopNumber: '37477',
|
||||
stopName: "O'Higgins - entre Angol y Salas",
|
||||
});
|
||||
|
||||
getNumber.mockReturnValue(20000).mockReturnValue(60000);
|
||||
});
|
||||
|
||||
it('should be defined', () => {
|
||||
|
@ -96,7 +108,9 @@ describe('useDevices tests', () => {
|
|||
it('should return a list of devices', async () => {
|
||||
const mockDate = new Date('2023-01-01T14:00:00Z');
|
||||
const spy = jest.spyOn(global, 'Date').mockImplementation(() => mockDate);
|
||||
|
||||
const {result} = renderHook(() => useDevices());
|
||||
|
||||
await waitFor(() => {
|
||||
expect(result.current.state.lines).toMatchObject([
|
||||
{
|
||||
|
@ -160,4 +174,50 @@ describe('useDevices tests', () => {
|
|||
|
||||
spy.mockRestore();
|
||||
});
|
||||
|
||||
it('should refresh devices list after 20000 miliseconds', async () => {
|
||||
const mockDate = new Date('2023-01-01T00:01:00Z');
|
||||
const spy = jest.spyOn(global, 'Date').mockImplementation(() => mockDate);
|
||||
jest
|
||||
.spyOn(DevicesRepositoryImpl.prototype, 'getDeviceInfo')
|
||||
.mockResolvedValue(mockResponse as any);
|
||||
|
||||
const {result} = renderHook(() => useDevices());
|
||||
|
||||
await waitFor(() => {
|
||||
expect(result.current.state.currentIndex).toBe(0);
|
||||
});
|
||||
|
||||
jest.advanceTimersByTime(20000);
|
||||
|
||||
await waitFor(() => {
|
||||
expect(result.current.state.currentIndex).toBe(22);
|
||||
});
|
||||
|
||||
spy.mockRestore();
|
||||
});
|
||||
|
||||
it('should refresh devices list after 60000 miliseconds', async () => {
|
||||
const mockDate = new Date('2023-01-01T00:01:00Z');
|
||||
const spy = jest.spyOn(global, 'Date').mockImplementation(() => mockDate);
|
||||
const spp = jest.spyOn(DevicesRepositoryImpl.prototype, 'getDeviceInfo');
|
||||
|
||||
const {result} = renderHook(() => useDevices());
|
||||
|
||||
expect(result.current.state.status).toBe(0);
|
||||
|
||||
await waitFor(() => {
|
||||
expect(spp).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
act(() => {
|
||||
jest.advanceTimersByTime(60000);
|
||||
});
|
||||
|
||||
await waitFor(() => {
|
||||
expect(spp).toHaveBeenCalledTimes(2);
|
||||
});
|
||||
|
||||
spy.mockRestore();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -0,0 +1,67 @@
|
|||
import {renderHook, waitFor} from '@testing-library/react-native';
|
||||
import useRemoteConfig from '../useRemoteConfig';
|
||||
import Status from '../../../utils/Status';
|
||||
import {
|
||||
setConfigSettings,
|
||||
setDefaults,
|
||||
fetchAndActivate,
|
||||
getString,
|
||||
} from '../../../../__mocks__/@react-native-firebase/remote-config';
|
||||
|
||||
describe('useRemoteconfig tests', () => {
|
||||
it('should be defined', async () => {
|
||||
expect(useRemoteConfig).toBeDefined();
|
||||
});
|
||||
|
||||
describe('on init hook', () => {
|
||||
beforeEach(() => {
|
||||
jest.clearAllMocks();
|
||||
});
|
||||
|
||||
it('should load remote config data succesfully', async () => {
|
||||
fetchAndActivate.mockResolvedValueOnce(true);
|
||||
|
||||
const {result} = renderHook(() => useRemoteConfig());
|
||||
|
||||
expect(result.current.status).toBe(Status.LOADING);
|
||||
|
||||
await waitFor(() => {
|
||||
expect(result.current.status).toBe(Status.SUCCESS);
|
||||
expect(setConfigSettings).toHaveBeenCalledTimes(1);
|
||||
expect(setDefaults).toHaveBeenCalledTimes(1);
|
||||
expect(fetchAndActivate).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
});
|
||||
|
||||
it('should fail to load remote config data', async () => {
|
||||
setConfigSettings.mockRejectedValueOnce(new Error('Error'));
|
||||
|
||||
const {result} = renderHook(() => useRemoteConfig());
|
||||
|
||||
expect(result.current.status).toBe(Status.LOADING);
|
||||
|
||||
await waitFor(() => {
|
||||
expect(result.current.status).toBe(Status.ERROR);
|
||||
expect(setConfigSettings).toHaveBeenCalledTimes(1);
|
||||
expect(fetchAndActivate).toHaveBeenCalledTimes(0);
|
||||
expect(setDefaults).toHaveBeenCalledTimes(0);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('get string', () => {
|
||||
it('should be defined', async () => {
|
||||
const {result} = renderHook(() => useRemoteConfig());
|
||||
|
||||
expect(result.current.getString).toBeDefined();
|
||||
});
|
||||
|
||||
it('should return a value', async () => {
|
||||
getString.mockReturnValueOnce('someValue');
|
||||
|
||||
const {result} = renderHook(() => useRemoteConfig());
|
||||
|
||||
expect(result.current.getString('someKey')).toStrictEqual('someValue');
|
||||
});
|
||||
});
|
||||
});
|
|
@ -10,8 +10,9 @@ import BusStopInfoService from '../../domain/services/BusStopInfoService';
|
|||
import RemoteConfigKeys from '../../utils/RemoteConfigKeys';
|
||||
import {Line} from '../../presentation/components/Table';
|
||||
import Status from '../../utils/Status';
|
||||
import {BUSES_BY_PAGE} from '../../domain/const';
|
||||
|
||||
interface State {
|
||||
export interface State {
|
||||
status: Status;
|
||||
lines: LineDetail[];
|
||||
displayedLines: Line[];
|
||||
|
@ -77,7 +78,7 @@ const useDevices = () => {
|
|||
busStopInfoService = new BusStopInfoService(linesWithArrivals);
|
||||
|
||||
const linesToDisplay: Line[] = busStopInfoService
|
||||
.pruneBusList(state.currentIndex, 21) // result 7 rows * 3 columns
|
||||
.pruneBusList(state.currentIndex, BUSES_BY_PAGE)
|
||||
.map(line => {
|
||||
try {
|
||||
const nextArraival = busStopInfoService.getNextArraival(
|
||||
|
@ -140,9 +141,17 @@ const useDevices = () => {
|
|||
);
|
||||
|
||||
useEffect(() => {
|
||||
let timeout: NodeJS.Timeout;
|
||||
|
||||
const init = async () => {
|
||||
try {
|
||||
setState((prevState: State) => ({
|
||||
...prevState,
|
||||
status: Status.LOADING,
|
||||
}));
|
||||
|
||||
const token = await authRepository.auth({username, password});
|
||||
|
||||
const {lineDetails, stopMessage} =
|
||||
await devicesRepository.getDeviceInfo({
|
||||
deviceId: DEVICE_ID,
|
||||
|
@ -177,14 +186,14 @@ const useDevices = () => {
|
|||
status: Status.ERROR,
|
||||
}));
|
||||
}
|
||||
|
||||
timeout = setTimeout(init, updateBusesListInterval);
|
||||
};
|
||||
|
||||
init();
|
||||
|
||||
const interval = setInterval(init, updateBusesListInterval);
|
||||
|
||||
return () => {
|
||||
clearInterval(interval);
|
||||
clearTimeout(timeout);
|
||||
};
|
||||
}, [
|
||||
authRepository,
|
||||
|
@ -199,22 +208,29 @@ const useDevices = () => {
|
|||
}, [setDisplayedLines, state.lines, state.stopMessage, state.stopName]);
|
||||
|
||||
useEffect(() => {
|
||||
const interval = setInterval(() => {
|
||||
let timeout: NodeJS.Timeout;
|
||||
|
||||
const init = () => {
|
||||
setState(prevState => {
|
||||
const isGreatherThanLinesLength =
|
||||
(prevState.currentIndex || 1) + 21 >= state.lines.length;
|
||||
(prevState.currentIndex || 1) + BUSES_BY_PAGE >= state.lines.length;
|
||||
|
||||
return {
|
||||
...prevState,
|
||||
currentIndex: isGreatherThanLinesLength
|
||||
? 0
|
||||
: (prevState.currentIndex || 1 + 21) % state.lines.length,
|
||||
: (prevState.currentIndex || 1 + BUSES_BY_PAGE) %
|
||||
state.lines.length,
|
||||
};
|
||||
});
|
||||
}, changePageInterval);
|
||||
|
||||
setTimeout(init, changePageInterval);
|
||||
};
|
||||
|
||||
init();
|
||||
|
||||
return () => {
|
||||
clearInterval(interval);
|
||||
clearTimeout(timeout);
|
||||
};
|
||||
}, [state.lines, state.status, changePageInterval]);
|
||||
|
||||
|
|
|
@ -2,6 +2,8 @@ import {useCallback, useEffect, useState} from 'react';
|
|||
import remoteConfig from '@react-native-firebase/remote-config';
|
||||
import Status from '../../utils/Status';
|
||||
|
||||
const ONE_HOUR = 3600000;
|
||||
|
||||
const useRemoteConfig = () => {
|
||||
const [status, setStatus] = useState(Status.LOADING);
|
||||
|
||||
|
@ -14,7 +16,7 @@ const useRemoteConfig = () => {
|
|||
const init = async () => {
|
||||
try {
|
||||
await remoteConfig().setConfigSettings({
|
||||
minimumFetchIntervalMillis: 3600000,
|
||||
minimumFetchIntervalMillis: ONE_HOUR,
|
||||
});
|
||||
|
||||
// TODO: Add default values for remote config
|
||||
|
@ -23,8 +25,8 @@ const useRemoteConfig = () => {
|
|||
HEADER_IMAGE_URL: '',
|
||||
USER: '',
|
||||
PASS: '',
|
||||
CHANGE_PAGE_INTERVAL: 0,
|
||||
UPDATE_BUSES_LIST_INTERVAL: 0,
|
||||
CHANGE_PAGE_INTERVAL: 0, // in miliseconds
|
||||
UPDATE_BUSES_LIST_INTERVAL: 0, // in miliseconds
|
||||
});
|
||||
|
||||
const isActivated = await remoteConfig().fetchAndActivate();
|
||||
|
|
|
@ -1,4 +1,10 @@
|
|||
import {View, ActivityIndicator, StyleProp} from 'react-native';
|
||||
import {
|
||||
View,
|
||||
ActivityIndicator,
|
||||
StyleProp,
|
||||
Text,
|
||||
StyleSheet,
|
||||
} from 'react-native';
|
||||
import {ViewStyle} from 'react-native';
|
||||
import Table, {Line} from './Table';
|
||||
import Status from '../../utils/Status';
|
||||
|
@ -9,11 +15,18 @@ interface BusListProps {
|
|||
style?: StyleProp<ViewStyle>;
|
||||
}
|
||||
|
||||
const ERROR_MESSAGE = 'Ha ocurrido un error';
|
||||
const EMPTY_MESSAGE = 'No buses available';
|
||||
|
||||
const BusList = ({buses, status, style}: BusListProps) => {
|
||||
return (
|
||||
<View style={style}>
|
||||
{status === Status.LOADING ? (
|
||||
<ActivityIndicator testID="LOADING" />
|
||||
{status === Status.LOADING && <ActivityIndicator testID="LOADING" />}
|
||||
{status === Status.ERROR && (
|
||||
<Text style={styles.text}>{ERROR_MESSAGE}</Text>
|
||||
)}
|
||||
{status === Status.SUCCESS && buses.length === 0 ? (
|
||||
<Text style={styles.text}>{EMPTY_MESSAGE}</Text>
|
||||
) : (
|
||||
<Table data={buses} />
|
||||
)}
|
||||
|
@ -21,4 +34,10 @@ const BusList = ({buses, status, style}: BusListProps) => {
|
|||
);
|
||||
};
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
text: {
|
||||
textAlign: 'center',
|
||||
},
|
||||
});
|
||||
|
||||
export default BusList;
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import {View, Text, StyleSheet} from 'react-native';
|
||||
import {COLUMNS, ROWS} from '../../domain/const';
|
||||
|
||||
export interface Line {
|
||||
lineNumber: string;
|
||||
|
@ -14,11 +15,8 @@ export interface TableProps {
|
|||
}
|
||||
|
||||
const Table = ({data}: TableProps) => {
|
||||
const rows = 7;
|
||||
const columns = 3;
|
||||
|
||||
const baseTableData: Line[][] = Array.from({length: rows}, () =>
|
||||
new Array(columns).fill({
|
||||
const baseTableData: Line[][] = Array.from({length: ROWS}, () =>
|
||||
new Array(COLUMNS).fill({
|
||||
lineNumber: '',
|
||||
lineLetter: '',
|
||||
letterColor: '',
|
||||
|
@ -28,8 +26,8 @@ const Table = ({data}: TableProps) => {
|
|||
);
|
||||
|
||||
data.map((item, index) => {
|
||||
const row = Math.floor(index / columns);
|
||||
const column = index % columns;
|
||||
const row = Math.floor(index / COLUMNS);
|
||||
const column = index % COLUMNS;
|
||||
baseTableData[row][column] = item;
|
||||
});
|
||||
|
||||
|
|
|
@ -5,11 +5,6 @@ exports[`BusList tests should render correctly with status LOADING 1`] = `
|
|||
<ActivityIndicator
|
||||
testID="LOADING"
|
||||
/>
|
||||
</View>
|
||||
`;
|
||||
|
||||
exports[`BusList tests should render correctly with status SUCCESS 1`] = `
|
||||
<View>
|
||||
<View
|
||||
style={
|
||||
{
|
||||
|
@ -294,3 +289,17 @@ exports[`BusList tests should render correctly with status SUCCESS 1`] = `
|
|||
</View>
|
||||
</View>
|
||||
`;
|
||||
|
||||
exports[`BusList tests should render correctly with status SUCCESS 1`] = `
|
||||
<View>
|
||||
<Text
|
||||
style={
|
||||
{
|
||||
"textAlign": "center",
|
||||
}
|
||||
}
|
||||
>
|
||||
No buses available
|
||||
</Text>
|
||||
</View>
|
||||
`;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import {ActivityIndicator, StyleSheet, View} from 'react-native';
|
||||
import {ActivityIndicator, StyleSheet, Text, View} from 'react-native';
|
||||
import Container from '../components/Container';
|
||||
import Header from '../components/Header';
|
||||
import useDevices from '../../infraestructure/hooks/useDevices';
|
||||
|
@ -9,9 +9,12 @@ import useRemoteConfig from '../../infraestructure/hooks/useRemoteConfig';
|
|||
import Status from '../../utils/Status';
|
||||
|
||||
const BANNER_TEXT = 'Buses que se detienen en esta parada';
|
||||
const ERROR_MESSAGE = 'Ha ocurrido un error';
|
||||
|
||||
const BusStopInfoScreen = () => {
|
||||
const {status, displayedLines, stopName} = useDevices().state;
|
||||
const {
|
||||
state: {status, displayedLines, stopName},
|
||||
} = useDevices();
|
||||
const {status: remoteConfigStatus, getString} = useRemoteConfig();
|
||||
|
||||
const image = getString(RemoteConfigKeys.HEADER_IMAGE_URL);
|
||||
|
@ -21,12 +24,20 @@ const BusStopInfoScreen = () => {
|
|||
|
||||
if (remoteConfigStatus === Status.LOADING) {
|
||||
return (
|
||||
<Container style={styles.container}>
|
||||
<Container style={styles.containerCenter}>
|
||||
<ActivityIndicator />
|
||||
</Container>
|
||||
);
|
||||
}
|
||||
|
||||
if (remoteConfigStatus === Status.ERROR) {
|
||||
return (
|
||||
<Container style={styles.containerCenter}>
|
||||
<Text>{ERROR_MESSAGE}</Text>
|
||||
</Container>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<Container style={styles.container}>
|
||||
<Header
|
||||
|
@ -42,7 +53,7 @@ const BusStopInfoScreen = () => {
|
|||
status={status}
|
||||
/>
|
||||
<View style={styles.footerContainer}>
|
||||
{/* {TODO implement footer} */}
|
||||
{/* {TODO: implement footer} */}
|
||||
</View>
|
||||
</Container>
|
||||
);
|
||||
|
@ -52,6 +63,10 @@ const styles = StyleSheet.create({
|
|||
container: {
|
||||
justifyContent: 'center',
|
||||
},
|
||||
containerCenter: {
|
||||
justifyContent: 'center',
|
||||
alignItems: 'center',
|
||||
},
|
||||
headerContainer: {
|
||||
flex: 1.5,
|
||||
backgroundColor: 'orange',
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
import App from '../App';
|
||||
|
||||
describe('App tests', () => {
|
||||
it('should be defined', () => {
|
||||
expect(App).toBeDefined();
|
||||
});
|
||||
});
|
|
@ -0,0 +1,615 @@
|
|||
import {render} from '@testing-library/react-native';
|
||||
import BusStopInfoScreen from '../BusStopInfoScreen';
|
||||
import * as useDevices from '../../../infraestructure/hooks/useDevices';
|
||||
import * as useRemoteConfig from '../../../infraestructure/hooks/useRemoteConfig';
|
||||
|
||||
const mockState: useDevices.State = {
|
||||
status: 1,
|
||||
currentIndex: 0,
|
||||
stopMessage: 'No considerar, uso futuro',
|
||||
displayedLines: [
|
||||
{
|
||||
backgroundColor: 'b10086',
|
||||
estimatedArrivalTimeInMinutes: 'Más de 10 minutos',
|
||||
lineLetter: 'N',
|
||||
lineNumber: '10',
|
||||
lineDescription: 'Vía Láctea - Los Bloques',
|
||||
letterColor: '',
|
||||
},
|
||||
{
|
||||
backgroundColor: '0071ca',
|
||||
estimatedArrivalTimeInMinutes: 'Más de 10 minutos',
|
||||
lineLetter: 'P',
|
||||
lineNumber: '10',
|
||||
lineDescription: 'Vía Láctea - Leonera',
|
||||
letterColor: '',
|
||||
},
|
||||
{
|
||||
backgroundColor: '4e0963',
|
||||
estimatedArrivalTimeInMinutes: 'Más de 10 minutos',
|
||||
lineLetter: 'L',
|
||||
lineNumber: '10',
|
||||
lineDescription: 'Vía Láctea - Los Bloques',
|
||||
letterColor: '',
|
||||
},
|
||||
{
|
||||
backgroundColor: 'ad0101',
|
||||
estimatedArrivalTimeInMinutes: 'Más de 10 minutos',
|
||||
lineLetter: 'Q',
|
||||
lineNumber: '11',
|
||||
lineDescription: 'Vía Futuro - Los Bloques',
|
||||
letterColor: '',
|
||||
},
|
||||
{
|
||||
backgroundColor: 'b10086',
|
||||
estimatedArrivalTimeInMinutes: 'Más de 10 minutos',
|
||||
lineLetter: 'R',
|
||||
lineNumber: '11',
|
||||
lineDescription: 'Vía Futuro - Porvenir',
|
||||
letterColor: '',
|
||||
},
|
||||
{
|
||||
backgroundColor: 'ce5504',
|
||||
estimatedArrivalTimeInMinutes: 'Más de 10 minutos',
|
||||
lineLetter: 'S',
|
||||
lineNumber: '13',
|
||||
lineDescription: 'Vía Siglo XXI - Leonera',
|
||||
letterColor: '',
|
||||
},
|
||||
{
|
||||
backgroundColor: 'ce5504',
|
||||
estimatedArrivalTimeInMinutes: 'Más de 10 minutos',
|
||||
lineLetter: 'T',
|
||||
lineNumber: '14',
|
||||
lineDescription: 'Chiguayante Sur - Coquimbo',
|
||||
letterColor: '',
|
||||
},
|
||||
{
|
||||
backgroundColor: 'cc9b00',
|
||||
estimatedArrivalTimeInMinutes: 'Más de 10 minutos',
|
||||
lineLetter: 'U',
|
||||
lineNumber: '14',
|
||||
lineDescription: 'Chiguayante Sur - Los Altos',
|
||||
letterColor: '',
|
||||
},
|
||||
{
|
||||
backgroundColor: 'ce5504',
|
||||
estimatedArrivalTimeInMinutes: 'Más de 10 minutos',
|
||||
lineLetter: 'K',
|
||||
lineNumber: '16',
|
||||
lineDescription: 'Vía Universo - Leonera',
|
||||
letterColor: '',
|
||||
},
|
||||
{
|
||||
backgroundColor: 'ad0101',
|
||||
estimatedArrivalTimeInMinutes: 'Más de 10 minutos',
|
||||
lineLetter: 'V',
|
||||
lineNumber: '16',
|
||||
lineDescription: 'Vía Universo - Leonera',
|
||||
letterColor: '',
|
||||
},
|
||||
{
|
||||
backgroundColor: '0d7215',
|
||||
estimatedArrivalTimeInMinutes: 'Más de 10 minutos',
|
||||
lineLetter: 'W',
|
||||
lineNumber: '17',
|
||||
lineDescription: 'Expresos Chiguayante - Leonera',
|
||||
letterColor: '',
|
||||
},
|
||||
{
|
||||
backgroundColor: 'ce5504',
|
||||
estimatedArrivalTimeInMinutes: 'Más de 10 minutos',
|
||||
lineLetter: 'X',
|
||||
lineNumber: '17',
|
||||
lineDescription: 'Expresos Chiguayante - Leonera',
|
||||
letterColor: '',
|
||||
},
|
||||
{
|
||||
backgroundColor: '0071ca',
|
||||
estimatedArrivalTimeInMinutes: 'Más de 10 minutos',
|
||||
lineLetter: 'Y',
|
||||
lineNumber: '18',
|
||||
lineDescription: 'Buses Palomares - Hualqui',
|
||||
letterColor: '',
|
||||
},
|
||||
{
|
||||
backgroundColor: 'b10086',
|
||||
estimatedArrivalTimeInMinutes: 'Más de 10 minutos',
|
||||
lineLetter: 'M',
|
||||
lineNumber: '20',
|
||||
lineDescription: 'Nueva Llacolén - San Pedro Costa',
|
||||
letterColor: '',
|
||||
},
|
||||
{
|
||||
backgroundColor: '0071ca',
|
||||
estimatedArrivalTimeInMinutes: 'Más de 10 minutos',
|
||||
lineLetter: 'A',
|
||||
lineNumber: '20',
|
||||
lineDescription: 'Nueva Llacolén - Boca Sur',
|
||||
letterColor: '',
|
||||
},
|
||||
{
|
||||
backgroundColor: '0071ca',
|
||||
estimatedArrivalTimeInMinutes: 'Más de 10 minutos',
|
||||
lineLetter: 'F',
|
||||
lineNumber: '24',
|
||||
lineDescription: 'San Remo - Candelaria',
|
||||
letterColor: '',
|
||||
},
|
||||
{
|
||||
backgroundColor: '0d7215',
|
||||
estimatedArrivalTimeInMinutes: 'Más de 10 minutos',
|
||||
lineLetter: 'Q',
|
||||
lineNumber: '30',
|
||||
lineDescription: 'Ruta Las Playas - Higueras',
|
||||
letterColor: '',
|
||||
},
|
||||
{
|
||||
backgroundColor: '049684',
|
||||
estimatedArrivalTimeInMinutes: 'Más de 10 minutos',
|
||||
lineLetter: 'R',
|
||||
lineNumber: '30',
|
||||
lineDescription: 'Ruta Las Playas - Higueras',
|
||||
letterColor: '',
|
||||
},
|
||||
{
|
||||
backgroundColor: 'ce5504',
|
||||
estimatedArrivalTimeInMinutes: 'Más de 10 minutos',
|
||||
lineLetter: 'P',
|
||||
lineNumber: '57',
|
||||
lineDescription: 'Denavi Sur - San Vicente',
|
||||
letterColor: '',
|
||||
},
|
||||
{
|
||||
backgroundColor: 'ad0101',
|
||||
estimatedArrivalTimeInMinutes: 'Más de 10 minutos',
|
||||
lineLetter: 'D',
|
||||
lineNumber: '31',
|
||||
lineDescription: 'Ruta del Mar - Lobos Viejos',
|
||||
letterColor: '',
|
||||
},
|
||||
{
|
||||
backgroundColor: 'ad0101',
|
||||
estimatedArrivalTimeInMinutes: 'Más de 10 minutos',
|
||||
lineLetter: 'G',
|
||||
lineNumber: '40',
|
||||
lineDescription: 'Las Golondrinas - Candelaria',
|
||||
letterColor: '',
|
||||
},
|
||||
],
|
||||
lines: [
|
||||
{
|
||||
lineNumber: 'Vía Láctea 10N - Los Bloques',
|
||||
description: '10N',
|
||||
locomotionType: 'Autobús',
|
||||
backgroundColor: 'b10086',
|
||||
letterColor: '',
|
||||
lineMessage: '',
|
||||
arrivals: [
|
||||
{planned: '', estimatedGPS: '21:57:47', distanceGPS: '', carPlate: ''},
|
||||
{planned: '', estimatedGPS: '22:11:13', distanceGPS: '', carPlate: ''},
|
||||
],
|
||||
},
|
||||
{
|
||||
lineNumber: 'Vía Láctea 10P - Leonera',
|
||||
description: '10P',
|
||||
locomotionType: 'Autobús',
|
||||
backgroundColor: '0071ca',
|
||||
letterColor: '',
|
||||
lineMessage: '',
|
||||
arrivals: [
|
||||
{planned: '', estimatedGPS: '22:11:15', distanceGPS: '', carPlate: ''},
|
||||
],
|
||||
},
|
||||
{
|
||||
lineNumber: 'Vía Láctea 10L - Los Bloques',
|
||||
description: '10L',
|
||||
locomotionType: 'Autobús',
|
||||
backgroundColor: '4e0963',
|
||||
letterColor: '',
|
||||
lineMessage: '',
|
||||
arrivals: [
|
||||
{planned: '', estimatedGPS: '22:11:15', distanceGPS: '', carPlate: ''},
|
||||
],
|
||||
},
|
||||
{
|
||||
lineNumber: 'Vía Futuro 11Q - Los Bloques',
|
||||
description: '11Q',
|
||||
locomotionType: 'Autobús',
|
||||
backgroundColor: 'ad0101',
|
||||
letterColor: '',
|
||||
lineMessage: '',
|
||||
arrivals: [
|
||||
{planned: '', estimatedGPS: '22:03:18', distanceGPS: '', carPlate: ''},
|
||||
],
|
||||
},
|
||||
{
|
||||
lineNumber: 'Vía Futuro 11R - Porvenir',
|
||||
description: '11R',
|
||||
locomotionType: 'Autobús',
|
||||
backgroundColor: 'b10086',
|
||||
letterColor: '',
|
||||
lineMessage: '',
|
||||
arrivals: [
|
||||
{planned: '', estimatedGPS: '22:10:32', distanceGPS: '', carPlate: ''},
|
||||
{planned: '', estimatedGPS: '21:58:25', distanceGPS: '', carPlate: ''},
|
||||
],
|
||||
},
|
||||
{
|
||||
lineNumber: 'Vía Siglo XXI 13S - Leonera',
|
||||
description: '13S',
|
||||
locomotionType: 'Autobús',
|
||||
backgroundColor: 'ce5504',
|
||||
letterColor: '',
|
||||
lineMessage: '',
|
||||
arrivals: [
|
||||
{planned: '', estimatedGPS: '22:05:47', distanceGPS: '', carPlate: ''},
|
||||
{planned: '', estimatedGPS: '22:03:29', distanceGPS: '', carPlate: ''},
|
||||
],
|
||||
},
|
||||
{
|
||||
lineNumber: 'Chiguayante Sur 14T - Coquimbo',
|
||||
description: '14T',
|
||||
locomotionType: 'Autobús',
|
||||
backgroundColor: 'ce5504',
|
||||
letterColor: '',
|
||||
lineMessage: '',
|
||||
arrivals: [
|
||||
{planned: '', estimatedGPS: '22:03:07', distanceGPS: '', carPlate: ''},
|
||||
{planned: '', estimatedGPS: '22:10:34', distanceGPS: '', carPlate: ''},
|
||||
],
|
||||
},
|
||||
{
|
||||
lineNumber: 'Chiguayante Sur 14U - Los Altos',
|
||||
description: '14U',
|
||||
locomotionType: 'Autobús',
|
||||
backgroundColor: 'cc9b00',
|
||||
letterColor: '',
|
||||
lineMessage: '',
|
||||
arrivals: [
|
||||
{planned: '', estimatedGPS: '21:58:12', distanceGPS: '', carPlate: ''},
|
||||
],
|
||||
},
|
||||
{
|
||||
lineNumber: 'Vía Universo 16K - Leonera',
|
||||
description: '16K',
|
||||
locomotionType: 'Autobús',
|
||||
backgroundColor: 'ce5504',
|
||||
letterColor: '',
|
||||
lineMessage: '',
|
||||
arrivals: [
|
||||
{planned: '', estimatedGPS: '21:56:07', distanceGPS: '', carPlate: ''},
|
||||
{planned: '', estimatedGPS: '22:03:34', distanceGPS: '', carPlate: ''},
|
||||
],
|
||||
},
|
||||
{
|
||||
lineNumber: 'Vía Universo 16V - Leonera',
|
||||
description: '16V',
|
||||
locomotionType: 'Autobús',
|
||||
backgroundColor: 'ad0101',
|
||||
letterColor: '',
|
||||
lineMessage: '',
|
||||
arrivals: [
|
||||
{planned: '', estimatedGPS: '21:55:51', distanceGPS: '', carPlate: ''},
|
||||
{planned: '', estimatedGPS: '22:03:50', distanceGPS: '', carPlate: ''},
|
||||
{planned: '', estimatedGPS: '21:51:59', distanceGPS: '', carPlate: ''},
|
||||
{planned: '', estimatedGPS: '22:11:13', distanceGPS: '', carPlate: ''},
|
||||
],
|
||||
},
|
||||
{
|
||||
lineNumber: 'Expresos Chiguayante 17W - Leonera',
|
||||
description: '17W',
|
||||
locomotionType: 'Autobús',
|
||||
backgroundColor: '0d7215',
|
||||
letterColor: '',
|
||||
lineMessage: '',
|
||||
arrivals: [
|
||||
{planned: '', estimatedGPS: '22:10:43', distanceGPS: '', carPlate: ''},
|
||||
],
|
||||
},
|
||||
{
|
||||
lineNumber: 'Expresos Chiguayante 17X - Leonera',
|
||||
description: '17X',
|
||||
locomotionType: 'Autobús',
|
||||
backgroundColor: 'ce5504',
|
||||
letterColor: '',
|
||||
lineMessage: '',
|
||||
arrivals: [
|
||||
{planned: '', estimatedGPS: '21:57:13', distanceGPS: '', carPlate: ''},
|
||||
{planned: '', estimatedGPS: '22:05:42', distanceGPS: '', carPlate: ''},
|
||||
{planned: '', estimatedGPS: '21:54:55', distanceGPS: '', carPlate: ''},
|
||||
],
|
||||
},
|
||||
{
|
||||
lineNumber: 'Buses Palomares 18Y - Hualqui',
|
||||
description: '18Y',
|
||||
locomotionType: 'Autobús',
|
||||
backgroundColor: '0071ca',
|
||||
letterColor: '',
|
||||
lineMessage: '',
|
||||
arrivals: [
|
||||
{planned: '', estimatedGPS: '22:10:11', distanceGPS: '', carPlate: ''},
|
||||
],
|
||||
},
|
||||
{
|
||||
lineNumber: 'Nueva Llacolén 20M - San Pedro Costa',
|
||||
description: '20M',
|
||||
locomotionType: 'Autobús',
|
||||
backgroundColor: 'b10086',
|
||||
letterColor: '',
|
||||
lineMessage: '',
|
||||
arrivals: [
|
||||
{planned: '', estimatedGPS: '22:08:19', distanceGPS: '', carPlate: ''},
|
||||
],
|
||||
},
|
||||
{
|
||||
lineNumber: 'Nueva Llacolén 20A - Boca Sur',
|
||||
description: '20A',
|
||||
locomotionType: 'Autobús',
|
||||
backgroundColor: '0071ca',
|
||||
letterColor: '',
|
||||
lineMessage: '',
|
||||
arrivals: [
|
||||
{planned: '', estimatedGPS: '21:55:19', distanceGPS: '', carPlate: ''},
|
||||
{planned: '', estimatedGPS: '22:09:49', distanceGPS: '', carPlate: ''},
|
||||
],
|
||||
},
|
||||
{
|
||||
lineNumber: 'San Remo 24F - Candelaria',
|
||||
description: '24F',
|
||||
locomotionType: 'Autobús',
|
||||
backgroundColor: '0071ca',
|
||||
letterColor: '',
|
||||
lineMessage: '',
|
||||
arrivals: [
|
||||
{planned: '', estimatedGPS: '21:51:14', distanceGPS: '', carPlate: ''},
|
||||
{planned: '', estimatedGPS: '21:43:17', distanceGPS: '', carPlate: ''},
|
||||
],
|
||||
},
|
||||
{
|
||||
lineNumber: 'Ruta Las Playas 30Q - Higueras',
|
||||
description: '30Q',
|
||||
locomotionType: 'Autobús',
|
||||
backgroundColor: '0d7215',
|
||||
letterColor: '',
|
||||
lineMessage: '',
|
||||
arrivals: [
|
||||
{planned: '', estimatedGPS: '22:00:38', distanceGPS: '', carPlate: ''},
|
||||
],
|
||||
},
|
||||
{
|
||||
lineNumber: 'Ruta Las Playas 30R - Higueras',
|
||||
description: '30R',
|
||||
locomotionType: 'Autobús',
|
||||
backgroundColor: '049684',
|
||||
letterColor: '',
|
||||
lineMessage: '',
|
||||
arrivals: [
|
||||
{planned: '', estimatedGPS: '21:50:33', distanceGPS: '', carPlate: ''},
|
||||
],
|
||||
},
|
||||
{
|
||||
lineNumber: 'Denavi Sur 57P - San Vicente',
|
||||
description: '57P',
|
||||
locomotionType: 'Autobús',
|
||||
backgroundColor: 'ce5504',
|
||||
letterColor: '',
|
||||
lineMessage: '',
|
||||
arrivals: [
|
||||
{planned: '', estimatedGPS: '22:06:08', distanceGPS: '', carPlate: ''},
|
||||
],
|
||||
},
|
||||
{
|
||||
lineNumber: 'Ruta del Mar 31D - Lobos Viejos',
|
||||
description: '31D',
|
||||
locomotionType: 'Autobús',
|
||||
backgroundColor: 'ad0101',
|
||||
letterColor: '',
|
||||
lineMessage: '',
|
||||
arrivals: [
|
||||
{planned: '', estimatedGPS: '22:10:32', distanceGPS: '', carPlate: ''},
|
||||
{planned: '', estimatedGPS: '22:10:34', distanceGPS: '', carPlate: ''},
|
||||
{planned: '', estimatedGPS: '22:06:41', distanceGPS: '', carPlate: ''},
|
||||
],
|
||||
},
|
||||
{
|
||||
lineNumber: 'Las Golondrinas 40G - Candelaria',
|
||||
description: '40G',
|
||||
locomotionType: 'Autobús',
|
||||
backgroundColor: 'ad0101',
|
||||
letterColor: '',
|
||||
lineMessage: '',
|
||||
arrivals: [
|
||||
{planned: '', estimatedGPS: '21:48:36', distanceGPS: '', carPlate: ''},
|
||||
],
|
||||
},
|
||||
{
|
||||
lineNumber: 'Buses Hualpencillo 42F - Concepción',
|
||||
description: '42F',
|
||||
locomotionType: 'Autobús',
|
||||
backgroundColor: 'ce5504',
|
||||
letterColor: '',
|
||||
lineMessage: '',
|
||||
arrivals: [
|
||||
{planned: '', estimatedGPS: '21:19:33', distanceGPS: '', carPlate: ''},
|
||||
],
|
||||
},
|
||||
{
|
||||
lineNumber: 'Mi Expreso 62M - San Vicente',
|
||||
description: '62M',
|
||||
locomotionType: 'Autobús',
|
||||
backgroundColor: '0071ca',
|
||||
letterColor: '',
|
||||
lineMessage: '',
|
||||
arrivals: [
|
||||
{planned: '', estimatedGPS: '22:02:34', distanceGPS: '', carPlate: ''},
|
||||
],
|
||||
},
|
||||
{
|
||||
lineNumber: 'Pedro de Valdivia 72K - Lonco',
|
||||
description: '72K',
|
||||
locomotionType: 'Autobús',
|
||||
backgroundColor: '0071ca',
|
||||
letterColor: '',
|
||||
lineMessage: '',
|
||||
arrivals: [
|
||||
{planned: '', estimatedGPS: '21:17:38', distanceGPS: '', carPlate: ''},
|
||||
{planned: '', estimatedGPS: '21:26:45', distanceGPS: '', carPlate: ''},
|
||||
],
|
||||
},
|
||||
{
|
||||
lineNumber: 'Nueva Sol Yet 90X - Parque Central',
|
||||
description: '90X',
|
||||
locomotionType: 'Autobús',
|
||||
backgroundColor: 'ad0101',
|
||||
letterColor: '',
|
||||
lineMessage: '',
|
||||
arrivals: [
|
||||
{planned: '', estimatedGPS: '21:39:48', distanceGPS: '', carPlate: ''},
|
||||
{planned: '', estimatedGPS: '21:47:30', distanceGPS: '', carPlate: ''},
|
||||
{planned: '', estimatedGPS: '21:52:24', distanceGPS: '', carPlate: ''},
|
||||
],
|
||||
},
|
||||
{
|
||||
lineNumber: 'Biobús B02 - Centro Concepción',
|
||||
description: 'B02',
|
||||
locomotionType: 'Autobús',
|
||||
backgroundColor: '0d7215',
|
||||
letterColor: '',
|
||||
lineMessage: '',
|
||||
arrivals: [
|
||||
{planned: '', estimatedGPS: '21:37:33', distanceGPS: '', carPlate: ''},
|
||||
],
|
||||
},
|
||||
{
|
||||
lineNumber: 'Las Bahías 70I - Centinela',
|
||||
description: '70I',
|
||||
locomotionType: 'Autobús',
|
||||
backgroundColor: '613FA6',
|
||||
letterColor: '',
|
||||
lineMessage: '',
|
||||
arrivals: [
|
||||
{planned: '', estimatedGPS: '22:05:39', distanceGPS: '', carPlate: ''},
|
||||
{planned: '', estimatedGPS: '22:09:26', distanceGPS: '', carPlate: ''},
|
||||
],
|
||||
},
|
||||
{
|
||||
lineNumber: 'Las Bahías 70J - Los Copihues',
|
||||
description: '70J',
|
||||
locomotionType: 'Autobús',
|
||||
backgroundColor: 'b38800',
|
||||
letterColor: '',
|
||||
lineMessage: '',
|
||||
arrivals: [
|
||||
{planned: '', estimatedGPS: '22:01:24', distanceGPS: '', carPlate: ''},
|
||||
],
|
||||
},
|
||||
{
|
||||
lineNumber: 'Las Galaxias 80Q - Hualqui',
|
||||
description: '80Q',
|
||||
locomotionType: 'Autobús',
|
||||
backgroundColor: 'ce5504',
|
||||
letterColor: '',
|
||||
lineMessage: '',
|
||||
arrivals: [
|
||||
{planned: '', estimatedGPS: '22:10:28', distanceGPS: '', carPlate: ''},
|
||||
{planned: '', estimatedGPS: '22:10:54', distanceGPS: '', carPlate: ''},
|
||||
{planned: '', estimatedGPS: '22:11:01', distanceGPS: '', carPlate: ''},
|
||||
],
|
||||
},
|
||||
{
|
||||
lineNumber: 'Las Galaxias 80H - Hualqui',
|
||||
description: '80H',
|
||||
locomotionType: 'Autobús',
|
||||
backgroundColor: '0071ca',
|
||||
letterColor: '',
|
||||
lineMessage: '',
|
||||
arrivals: [
|
||||
{planned: '', estimatedGPS: '22:10:23', distanceGPS: '', carPlate: ''},
|
||||
{planned: '', estimatedGPS: '22:10:32', distanceGPS: '', carPlate: ''},
|
||||
],
|
||||
},
|
||||
{
|
||||
lineNumber: 'Las Galaxias 80Z - Valle Piedra',
|
||||
description: '80Z',
|
||||
locomotionType: 'Autobús',
|
||||
backgroundColor: '0d7215',
|
||||
letterColor: '',
|
||||
lineMessage: '',
|
||||
arrivals: [
|
||||
{planned: '', estimatedGPS: '22:06:08', distanceGPS: '', carPlate: ''},
|
||||
{planned: '', estimatedGPS: '22:10:02', distanceGPS: '', carPlate: ''},
|
||||
{planned: '', estimatedGPS: '22:11:02', distanceGPS: '', carPlate: ''},
|
||||
{planned: '', estimatedGPS: '21:54:16', distanceGPS: '', carPlate: ''},
|
||||
{planned: '', estimatedGPS: '22:01:17', distanceGPS: '', carPlate: ''},
|
||||
],
|
||||
},
|
||||
{
|
||||
lineNumber: 'Ruta del Mar 32E - Lobos Viejos',
|
||||
description: '32E',
|
||||
locomotionType: 'Autobús',
|
||||
backgroundColor: 'b10086',
|
||||
letterColor: '',
|
||||
lineMessage: '',
|
||||
arrivals: [
|
||||
{planned: '', estimatedGPS: '22:05:08', distanceGPS: '', carPlate: ''},
|
||||
{planned: '', estimatedGPS: '22:10:28', distanceGPS: '', carPlate: ''},
|
||||
],
|
||||
},
|
||||
{
|
||||
lineNumber: 'Ruta del Mar 32J - Lobos Viejos',
|
||||
description: '32J',
|
||||
locomotionType: 'Autobús',
|
||||
backgroundColor: '598200',
|
||||
letterColor: '',
|
||||
lineMessage: '',
|
||||
arrivals: [
|
||||
{planned: '', estimatedGPS: '22:09:44', distanceGPS: '', carPlate: ''},
|
||||
],
|
||||
},
|
||||
],
|
||||
stopName: "O'Higgins -esq. Salas",
|
||||
};
|
||||
|
||||
describe('BusStopInfoScreen tests', () => {
|
||||
beforeAll(() => {
|
||||
jest.spyOn(useDevices, 'default').mockReturnValue({
|
||||
state: mockState,
|
||||
});
|
||||
});
|
||||
|
||||
it('should be defined', () => {
|
||||
expect(BusStopInfoScreen).toBeDefined();
|
||||
});
|
||||
|
||||
it('should render the screen with status loading', () => {
|
||||
jest.spyOn(useRemoteConfig, 'default').mockReturnValue({
|
||||
status: 0,
|
||||
getString: () => 'https://www.google.com',
|
||||
});
|
||||
const {toJSON} = render(<BusStopInfoScreen />);
|
||||
|
||||
expect(toJSON()).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('should render the screen with status error', () => {
|
||||
jest.spyOn(useRemoteConfig, 'default').mockReturnValue({
|
||||
status: 2,
|
||||
getString: () => 'https://www.google.com',
|
||||
});
|
||||
|
||||
const {toJSON} = render(<BusStopInfoScreen />);
|
||||
|
||||
expect(toJSON()).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('should render the screen with status success', () => {
|
||||
jest.spyOn(useRemoteConfig, 'default').mockReturnValue({
|
||||
status: 1,
|
||||
getString: () => 'https://www.google.com',
|
||||
});
|
||||
const {toJSON} = render(<BusStopInfoScreen />);
|
||||
|
||||
expect(toJSON()).toMatchSnapshot();
|
||||
});
|
||||
});
|
File diff suppressed because it is too large
Load Diff
11
yarn.lock
11
yarn.lock
|
@ -1908,13 +1908,16 @@
|
|||
integrity sha512-Im93xRJuHHxb1wniGhBMsxLwcfzdYreSZVQGDoMJgkd6+Iky61LInGEHnQCTN0fKNYF1Dvcofb4uMmE1RQHXHQ==
|
||||
|
||||
"@react-native/codegen@^0.72.7":
|
||||
version "0.72.7"
|
||||
resolved "https://registry.yarnpkg.com/@react-native/codegen/-/codegen-0.72.7.tgz#b6832ce631ac63143024ea094a6b5480a780e589"
|
||||
integrity sha512-O7xNcGeXGbY+VoqBGNlZ3O05gxfATlwE1Q1qQf5E38dK+tXn5BY4u0jaQ9DPjfE8pBba8g/BYI1N44lynidMtg==
|
||||
version "0.72.8"
|
||||
resolved "https://registry.yarnpkg.com/@react-native/codegen/-/codegen-0.72.8.tgz#0593f628e1310f430450a9479fbb4be35e7b63d6"
|
||||
integrity sha512-jQCcBlXV7B7ap5VlHhwIPieYz89yiRgwd2FPUBu+unz+kcJ6pAiB2U8RdLDmyIs8fiWd+Vq1xxaWs4TR329/ng==
|
||||
dependencies:
|
||||
"@babel/parser" "^7.20.0"
|
||||
flow-parser "^0.206.0"
|
||||
glob "^7.1.1"
|
||||
invariant "^2.2.4"
|
||||
jscodeshift "^0.14.0"
|
||||
mkdirp "^0.5.1"
|
||||
nullthrows "^1.1.1"
|
||||
|
||||
"@react-native/eslint-config@^0.72.2":
|
||||
|
@ -4007,7 +4010,7 @@ glob-parent@^6.0.2:
|
|||
dependencies:
|
||||
is-glob "^4.0.3"
|
||||
|
||||
glob@^7.1.3, glob@^7.1.4:
|
||||
glob@^7.1.1, glob@^7.1.3, glob@^7.1.4:
|
||||
version "7.2.3"
|
||||
resolved "https://registry.yarnpkg.com/glob/-/glob-7.2.3.tgz#b8df0fb802bbfa8e89bd1d938b4e16578ed44f2b"
|
||||
integrity sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==
|
||||
|
|
Loading…
Reference in New Issue