From 5c44e96cc0d13f83d0b693f880b700065a2fb8b8 Mon Sep 17 00:00:00 2001 From: Nicolas Fritz Date: Wed, 18 Jan 2023 20:05:53 +0100 Subject: [PATCH] =?UTF-8?q?PlusAmount=20SpecialKarte=20hinzugef=C3=BCgt=20?= =?UTF-8?q?+=20UnitTest?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- uno/js/cards/special/PlusAmount.js | 14 ++++++++++++++ uno/tests/test_Card.test.js | 29 +++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 uno/js/cards/special/PlusAmount.js diff --git a/uno/js/cards/special/PlusAmount.js b/uno/js/cards/special/PlusAmount.js new file mode 100644 index 0000000..bdbc43f --- /dev/null +++ b/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; \ No newline at end of file diff --git a/uno/tests/test_Card.test.js b/uno/tests/test_Card.test.js index 04c75ce..d42c71b 100644 --- a/uno/tests/test_Card.test.js +++ b/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