From 14f44ee21fc3bea43ab2f5d2edcb095358c0e932 Mon Sep 17 00:00:00 2001 From: Nicolas Fritz Date: Wed, 18 Jan 2023 19:58:26 +0100 Subject: [PATCH] SpecialKarten erstellt + UnitTests - ChooseColor - Reverse - Skip --- uno/js/cards/special/ChooseColor.js | 10 ++++++++ uno/js/cards/special/Reverse.js | 8 +++++++ uno/js/cards/special/Skip.js | 9 ++++++++ uno/tests/test_Card.test.js | 36 +++++++++++++++++++++++++++++ 4 files changed, 63 insertions(+) create mode 100644 uno/js/cards/special/ChooseColor.js create mode 100644 uno/js/cards/special/Reverse.js create mode 100644 uno/js/cards/special/Skip.js diff --git a/uno/js/cards/special/ChooseColor.js b/uno/js/cards/special/ChooseColor.js new file mode 100644 index 0000000..591a776 --- /dev/null +++ b/uno/js/cards/special/ChooseColor.js @@ -0,0 +1,10 @@ +const Card = require('../Card'); +const uno = require('../../uno'); + +class ChooseColor extends Card { + constructor(name) { + super(name, uno.CARD_COLORS[0]); + } +} + +module.exports = ChooseColor; \ No newline at end of file diff --git a/uno/js/cards/special/Reverse.js b/uno/js/cards/special/Reverse.js new file mode 100644 index 0000000..dd9ceb7 --- /dev/null +++ b/uno/js/cards/special/Reverse.js @@ -0,0 +1,8 @@ +const Card = require('../Card'); + +class Reverse extends Card { + constructor(name, color) { + super(name, color); + } +} +module.exports = Reverse; \ No newline at end of file diff --git a/uno/js/cards/special/Skip.js b/uno/js/cards/special/Skip.js new file mode 100644 index 0000000..1e80281 --- /dev/null +++ b/uno/js/cards/special/Skip.js @@ -0,0 +1,9 @@ +const Card = require('../Card'); + +class Skip extends Card { + constructor(name, color) { + super(name, color); + } +} + +module.exports = Skip; \ No newline at end of file diff --git a/uno/tests/test_Card.test.js b/uno/tests/test_Card.test.js index b55b580..04c75ce 100644 --- a/uno/tests/test_Card.test.js +++ b/uno/tests/test_Card.test.js @@ -1,6 +1,9 @@ //Imports const uno = require('../js/uno'); 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'); //Instanz CARD_COLORS aus uno.js const CARD_COLORS = uno.CARD_COLORS; @@ -32,6 +35,39 @@ describe('Karten erstellen', () => { }); + it('ChooseColor', () => { + + //Erstellen einer +2 Karte: + //Name: CC, Farbe: keine + card = new ChooseColor('CC'); + + //Testet das Erstellen der Karte + testCreatedCard(card, 'CC', "NONE"); + + }); + + it('Skip - Gelb', () => { + + //Erstellen einer Skip Karte: + //Name: Skip, Farbe: gelb + card = new Skip('S', CARD_COLORS[4]); + + //Testet das Erstellen der Karte + testCreatedCard(card, 'S', "YELLOW"); + + }); + + it('Reverse - Grün', () => { + + //Erstellen einer Reverse Karte: + //Name: Reverse, Farbe: grün + card = new Reverse('R', CARD_COLORS[2]); + + //Testet das Erstellen der Karte + testCreatedCard(card, 'R', "GREEN"); + + }); + }); //Testet eine Karte auf die Eigenschaften von Card.js