34 | );
35 | }
36 |
37 | export default App;
38 |
--------------------------------------------------------------------------------
/public/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
12 |
13 |
17 |
18 |
27 | React App
28 |
29 |
30 |
31 |
32 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/src/logo.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Getting Started with Create React App
2 |
3 | This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
4 |
5 | ## Available Scripts
6 |
7 | In the project directory, you can run:
8 |
9 | ### `npm start`
10 |
11 | Runs the app in the development mode.\
12 | Open [http://localhost:3000](http://localhost:3000) to view it in your browser.
13 |
14 | The page will reload when you make changes.\
15 | You may also see any lint errors in the console.
16 |
17 | ### `npm test`
18 |
19 | Launches the test runner in the interactive watch mode.\
20 | See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
21 |
22 | ### `npm run build`
23 |
24 | Builds the app for production to the `build` folder.\
25 | It correctly bundles React in production mode and optimizes the build for the best performance.
26 |
27 | The build is minified and the filenames include the hashes.\
28 | Your app is ready to be deployed!
29 |
30 | See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
31 |
32 | ### `npm run eject`
33 |
34 | **Note: this is a one-way operation. Once you `eject`, you can't go back!**
35 |
36 | If you aren't satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
37 |
38 | Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you're on your own.
39 |
40 | You don't have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn't feel obligated to use this feature. However we understand that this tool wouldn't be useful if you couldn't customize it when you are ready for it.
41 |
42 | ## Learn More
43 |
44 | You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
45 |
46 | To learn React, check out the [React documentation](https://reactjs.org/).
47 |
48 | ### Code Splitting
49 |
50 | This section has moved here: [https://facebook.github.io/create-react-app/docs/code-splitting](https://facebook.github.io/create-react-app/docs/code-splitting)
51 |
52 | ### Analyzing the Bundle Size
53 |
54 | This section has moved here: [https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size](https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size)
55 |
56 | ### Making a Progressive Web App
57 |
58 | This section has moved here: [https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app](https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app)
59 |
60 | ### Advanced Configuration
61 |
62 | This section has moved here: [https://facebook.github.io/create-react-app/docs/advanced-configuration](https://facebook.github.io/create-react-app/docs/advanced-configuration)
63 |
64 | ### Deployment
65 |
66 | This section has moved here: [https://facebook.github.io/create-react-app/docs/deployment](https://facebook.github.io/create-react-app/docs/deployment)
67 |
68 | ### `npm run build` fails to minify
69 |
70 | This section has moved here: [https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify](https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify)
71 |
--------------------------------------------------------------------------------
/src/App.test.js:
--------------------------------------------------------------------------------
1 | import { fireEvent, render, screen } from '@testing-library/react';
2 | import '@testing-library/jest-dom';
3 | import App from './App';
4 |
5 | const mockArray = [{"changeuuid":"35b964f4-e826-4e41-adcb-799c6f56f5b6",
6 | "stationuuid":"0fa1bfa4-f365-11e8-a471-52543be04c81",
7 | "serveruuid":"c54c69a7-9175-4a27-9b13-e6fabc997b90","name":"- 0 N - Jazz on Radio",
8 | "url":"https://0n-jazz.radionetz.de/0n-jazz.aac",
9 | "url_resolved":"https://0n-jazz.radionetz.de/0n-jazz.aac","homepage":"http://www.0nradio.com/",
10 | "favicon":"https://www.0nradio.com/logos/0n-jazz_600x600.jpg","tags":"jazz,smooth jazz,swing",
11 | "country":"Germany","countrycode":"DE","iso_3166_2":"DE-BY","state":"Bavaria",
12 | "language":"german","languagecodes":"DE,de","votes":116,
13 | "lastchangetime":"2022-05-02 10:06:52","lastchangetime_iso8601":"2022-05-02T10:06:52Z",
14 | "codec":"AAC+","bitrate":64,"hls":0,"lastcheckok":1,"lastchecktime":"2022-10-07 14:10:21",
15 | "lastchecktime_iso8601":"2022-10-07T14:10:21Z","lastcheckoktime":"2022-10-07 14:10:21",
16 | "lastcheckoktime_iso8601":"2022-10-07T14:10:21Z",
17 | "lastlocalchecktime":"2022-10-07 09:15:53","lastlocalchecktime_iso8601":"2022-10-07T09:15:53Z",
18 | "clicktimestamp":"2022-10-07 13:38:34","clicktimestamp_iso8601":"2022-10-07T13:38:34Z",
19 | "clickcount":41,"clicktrend":4,"ssl_error":0,"geo_lat":50.3115,"geo_long":11.923,
20 | "has_extended_info":true}]
21 |
22 | beforeEach(() => render())
23 |
24 |
25 | /*test('renders learn react link', () => {
26 | render();
27 | const linkElement = screen.getByText(/learn react/i);
28 | expect(linkElement).toBeInTheDocument();
29 | });*/
30 | // Vamos a construir una aplicación de seleción y búsqueda de Emisoras de Radio en Streaming
31 |
32 | // 0 - La aplicación debe renderizar correctamente
33 | describe('0 - La aplicación debe renderizar correctamente', () => {
34 | test('0 - La aplicación debe renderizar correctamente', () => {
35 | const r = render()
36 | expect(r).toBeDefined();
37 | })
38 |
39 | });
40 |
41 | // 1 - El nombre de la aplicacion debe mostrarse en algún lugar -> "OpenRadioCamp"
42 | describe('1 - El nombre de la aplicacion debe mostrarse en algún lugar -> "OpenRadioCamp"', () => {
43 | test('1 - El nombre de la aplicacion debe mostrarse en algún lugar -> "OpenRadioCamp"', () => {
44 | const nombre = "OpenRadioCamp"
45 | const el = screen.getByText(nombre)
46 | expect(el).toBeInTheDocument();
47 | })
48 |
49 | });
50 |
51 | // 2 - Debemos podemos buscar radios por nombre
52 | // 2a - La aplicacion debe tener un campo input con el placeholder => "Escribe el nombre de la radio"
53 | // 2b - La aplicación debe tener un botón de búsqueda => Texto "Buscar"
54 | // 2c - Cuando hacemos clic en el botón buscar, se debe ejecutar la función de búsqueda una sola vez
55 | describe('2 - Debemos podemos buscar radios por nombre', () => {
56 | test('2a - La aplicacion debe tener un campo input con el placeholder => "Escribe el nombre de la radio"', () => {
57 | const placeholdertext = "Escribe el nombre de la radio";
58 | const input = screen.getByPlaceholderText(placeholdertext);
59 | expect(input).toBeInTheDocument();
60 | })
61 | test('2b - La aplicación debe tener un botón de búsqueda => Texto "Buscar"', () => {
62 | const buttontext = "Buscar";
63 | const button = screen.getByText(buttontext);
64 | expect(button).toBeInTheDocument();
65 | })
66 | test('2c - Cuando hacemos clic en el botón buscar, se debe ejecutar la función de búsqueda una sola vez"', () => {
67 | const funcionMock = jest.fn();
68 | const buttontext = "Buscar";
69 | const button = screen.getByText(buttontext);
70 | button.addEventListener('click', funcionMock);
71 | fireEvent.click(button);
72 | expect(funcionMock).toHaveBeenCalledTimes(1);
73 | })
74 | })
75 |
76 | // 3 - Listado de emisoras
77 | // 3a - Debe existir un listado de emisoras
78 | // 3b - El listado debe inicializar vacío
79 | // 3c - Cuando se hace una búsqueda válida, el listado debe mostrar al menos un resultado
80 | // 3d - Cuando hacemos una búsqueda inválida (no existe), el listado debe mostrar un mensaje => 'No se han encontrado emisoras para esta búsqueda'
81 | describe('3 - Listado de emisoras ', () => {
82 | test('3a - Debe existir un listado de emisoras ', () => {
83 | const listado = screen.getByLabelText('listado-emisoras')
84 | expect(listado).toBeInTheDocument();
85 | })
86 | test('3b - El listado debe inicializar vacío', () => {
87 | const listado = screen.getByLabelText('listado-emisoras')
88 | const childrenCount = listado.childElementCount;
89 | expect(childrenCount).toBe(0);
90 | })
91 | test('3c - Cuando se hace una búsqueda válida, el listado debe mostrar al menos un resultado', () => {
92 | const placeholdertext = "Escribe el nombre de la radio";
93 | const input = screen.getByPlaceholderText(placeholdertext);
94 | const buttontext = "Buscar";
95 | const button = screen.getByText(buttontext);
96 | fireEvent.change(input, { target: { value: 'Country' }})
97 | fireEvent.click(button);
98 | const listado = screen.getByLabelText('listado-emisoras')
99 | const childrenCount = listado.childElementCount;
100 | expect(childrenCount).toBeGreaterThanOrEqual(0);
101 | })
102 | });
103 |
--------------------------------------------------------------------------------