File tree Expand file tree Collapse file tree 2 files changed +26
-4
lines changed Expand file tree Collapse file tree 2 files changed +26
-4
lines changed Original file line number Diff line number Diff line change @@ -37,7 +37,8 @@ export class Carrito {
3737 }
3838 }
3939
40- removeItem ( ) {
41- return [ ] ;
40+ removeItem ( item ) {
41+ this . items = this . items . filter ( ( i ) => i . name !== item . name ) ;
42+ return this . items ;
4243 }
4344}
Original file line number Diff line number Diff line change @@ -123,8 +123,29 @@ describe("Testing de la clase Carrito", () => {
123123 expect ( carrito . removeItem ( waterItem ) ) . toHaveLength ( 0 ) ;
124124 } ) ;
125125
126- it . todo (
127- "Carrito.removeItem debe devolver un array con un elemento cuando añadimos dos elementos distintos y eliminamos uno"
126+ it ( "Carrito.removeItem debe devolver un array con un elemento cuando añadimos dos elementos distintos y eliminamos uno" , ( ) => {
127+ carrito . addItem ( sushiItem ) ;
128+ carrito . addItem ( waterItem ) ;
129+ expect ( carrito . removeItem ( waterItem ) ) . toHaveLength ( 1 ) ;
130+ } ) ;
131+
132+ it ( "Carrito.items debe contener un elemento después de añadir dos elementos distintos y eliminar uno" , ( ) => {
133+ carrito . addItem ( sushiItem ) ;
134+ carrito . addItem ( waterItem ) ;
135+ carrito . removeItem ( waterItem ) ;
136+ expect ( carrito . items ) . toHaveLength ( 1 ) ;
137+ } ) ;
138+
139+ /* it.todo(
140+ "Carrito.items debe ser un array con DOS elementos si añadimos dos sushiItem y un waterItem y eliminamos un sushiItem"
128141 );
142+
143+ it("", () => {
144+ carrito.addItem(sushiItem);
145+ carrito.addItem(sushiItem);
146+ carrito.addItem(waterItem);
147+ carrito.removeItem(sushiItem);
148+ expect(carrito.items).toHaveLength(2);
149+ }); */
129150 } ) ;
130151} ) ;
You can’t perform that action at this time.
0 commit comments