Skip to content

Commit

Permalink
Correcciones
Browse files Browse the repository at this point in the history
  • Loading branch information
juanmanuelgg committed Jul 17, 2022
1 parent 99b2272 commit 46ea016
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 39 deletions.
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// eslint-disable-next-line no-undef
module.exports = {
settings: { react: { version: 'detect' } },
env: {
browser: true,
es2021: true
Expand Down
2 changes: 1 addition & 1 deletion cypress/component/Helper/Stepper.cy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* https://docs.cypress.io/guides/component-testing/testing-react
*/
import * as React from 'react';
import { Stepper } from '../../../dist/esm/components/Helper/Stepper';
import { Stepper } from '../../../';

const stepperSelector = '[data-testid=stepper]';
const incrementSelector = '[aria-label=increment]';
Expand Down
16 changes: 8 additions & 8 deletions cypress/component/Helper/StepperEvents.cy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,34 +5,34 @@
* https://docs.cypress.io/guides/component-testing/events-react
*/
import * as React from 'react';
import { Stepper } from '../../../dist/esm/components/Helper/StepperEvents';
import { StepperEvents } from '../../../';

const stepperSelector = '[data-testid=stepper]';
const incrementSelector = '[aria-label=increment]';
const decrementSelector = '[aria-label=decrement]';

describe('<Stepper>', () => {
it('mounts', () => {
cy.mount(<Stepper />);
cy.mount(<StepperEvents />);
});

it('stepper should default to 0', () => {
// Arrange
cy.mount(<Stepper />);
cy.mount(<StepperEvents />);
// Assert
cy.get(stepperSelector).should('contain.text', 0);
});

it('supports an "initial" prop to set the value', () => {
// Arrange
cy.mount(<Stepper initial={100} />);
cy.mount(<StepperEvents initial={100} />);
// Assert
cy.get(stepperSelector).should('contain.text', 100);
});

it('can be incremented', () => {
// Arrange
cy.mount(<Stepper />);
cy.mount(<StepperEvents />);
// Act
cy.get(incrementSelector).click();
// Assert
Expand All @@ -41,15 +41,15 @@ describe('<Stepper>', () => {

it('can be decremented', () => {
// Arrange
cy.mount(<Stepper />);
cy.mount(<StepperEvents />);
// Act
cy.get(decrementSelector).click();
// Assert
cy.get(stepperSelector).should('contain.text', -1);
});

it('has an initial counter that can be incremented and decremented', () => {
cy.mount(<Stepper initial={100} />);
cy.mount(<StepperEvents initial={100} />);
cy.get(stepperSelector).should('contain.text', 100);
cy.get(incrementSelector).click();
cy.get(stepperSelector).should('contain.text', 101);
Expand All @@ -60,7 +60,7 @@ describe('<Stepper>', () => {
it('clicking + fires a change event with the incremented value', () => {
// Arrange
const onChangeSpy = cy.spy().as('onChangeSpy');
cy.mount(<Stepper initial={150} onChange={onChangeSpy} />);
cy.mount(<StepperEvents initial={150} onChange={onChangeSpy} />);
// Act
cy.get(incrementSelector).click();
// Assert
Expand Down
2 changes: 1 addition & 1 deletion cypress/component/SpeedDial.cy.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import { SpeedDial } from '../../dist/esm/components/SpeedDial';
import { SpeedDial } from '../../';

describe('SpeedDial.cy.tsx', () => {
// ============================================================================================
Expand Down
20 changes: 0 additions & 20 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
"name": "@bonapata/partes",
"version": "0.2.4",
"description": "Una librería libre de componentes para React, escrita en Typescript.",
"main": "dist/cjs/index.js",
"main": "dist/csj/index.js",
"browser": "dist/csj/index.js",
"module": "dist/esm/index.js",
"types": "./dist/esm/index.d.ts",
"files": [
"dist",
"src"
Expand All @@ -13,7 +15,6 @@
"@babel/preset-env": "^7.18.6",
"@babel/preset-react": "^7.18.6",
"@cypress/react": "^6.0.0",
"@types/cypress": "^1.1.3",
"@types/jest": "^28.1.4",
"@types/node": "^18.0.1",
"@types/react": "^17.0.39",
Expand Down Expand Up @@ -47,6 +48,7 @@
"build:cjs": "tsc --module CommonJS --outDir dist/cjs",
"pretest": "npm run build",
"test": "cypress run --component",
"pretest:open": "npm run build",
"test:open": "cypress open --component --browser chrome"
},
"repository": {
Expand All @@ -61,7 +63,6 @@
],
"author": "Juan Manuel González Garzón",
"license": "Unlicense",
"types": "./dist/cjs/index.d.ts",
"bugs": {
"url": "https://github.com/juanmanuelgg/bonapata-partes/issues"
},
Expand Down
6 changes: 3 additions & 3 deletions src/components/Helper/StepperEvents.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import React, { useState } from 'react';

export interface StepperProps {
export interface StepperEventsProps {
initial?: number;
onChange?: (count: number) => void;
}

export const Stepper: React.FunctionComponent<StepperProps> = (
props: StepperProps
export const StepperEvents: React.FunctionComponent<StepperEventsProps> = (
props: StepperEventsProps
) => {
const {
initial = 0,
Expand Down
1 change: 1 addition & 0 deletions src/components/Helper/index.tsx
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export * from './Stepper';
export * from './StepperEvents';
12 changes: 9 additions & 3 deletions src/components/SpeedDial.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useState } from 'react';
import React, { useState, useMemo } from 'react';

interface IconContentProps {
pathname: string;
Expand Down Expand Up @@ -44,8 +44,14 @@ export const SpeedDial: React.FunctionComponent<SpeedDialProps> = (
} = props;

const savedFavorites: string = localStorage.getItem('favorites') || '[]';
let favorites: string[] = Array.from(new Set(JSON.parse(savedFavorites)));
localStorage.setItem('favorites', JSON.stringify(favorites));
let favorites: string[] = useMemo(() => {
const answer: string[] = Array.from(
new Set(JSON.parse(savedFavorites))
);
if (savedFavorites.length !== answer.length)
localStorage.setItem('favorites', JSON.stringify(answer));
return answer;
}, [saveFavorite]);

const show = new Array(favorites.length);
show.fill(false);
Expand Down

0 comments on commit 46ea016

Please sign in to comment.