Browse Source

PlusAmount SpecialKarte hinzugefügt + UnitTest

main
Nicolas Fritz 2 years ago
parent
commit
5c44e96cc0
  1. 14
      uno/js/cards/special/PlusAmount.js
  2. 29
      uno/tests/test_Card.test.js

14
uno/js/cards/special/PlusAmount.js

@ -0,0 +1,14 @@
const uno = require('../../uno');
const Card = require('../Card');
class PlusAmount extends Card {
constructor(name, color = uno.CARD_COLORS[0]) {
super(name, color);
if (color === uno.CARD_COLORS[0]) this._plus = 4; else this._plus = 2;
}
get plus() {
return this._plus;
}
}
module.exports = PlusAmount;

29
uno/tests/test_Card.test.js

@ -4,6 +4,7 @@ const Card = require('../js/cards/Card');
const ChooseColor = require('../js/cards/special/ChooseColor');
const Skip = require('../js/cards/special/Skip');
const Reverse = require('../js/cards/special/Reverse');
const PlusAmount = require('../js/cards/special/PlusAmount');
//Instanz CARD_COLORS aus uno.js
const CARD_COLORS = uno.CARD_COLORS;
@ -68,6 +69,34 @@ describe('Karten erstellen', () => {
});
it('+4', () => {
//Erstellen einer +4 Karte:
//Name: +4, Farbe: keine
card = new PlusAmount('+4');
//Testet das Erstellen der Karte
testCreatedCard(card, '+4', "NONE");
//PlusAmount muss 4 sein
expect(card.plus).toBe(4);
});
it('+2 - Rot', () => {
//Erstellen einer +2 Karte:
//Name: +2, Farbe: Rot
card = new PlusAmount('+2', CARD_COLORS[3]);
//Testet das Erstellen der Karte
testCreatedCard(card, '+2', "RED");
//PlusAmount muss 2 sein
expect(card.plus).toBe(2);
});
});
//Testet eine Karte auf die Eigenschaften von Card.js

Loading…
Cancel
Save