From f71618872a1dd8414801155331bd76d81ddb3a71 Mon Sep 17 00:00:00 2001 From: Nicolas Fritz Date: Wed, 18 Jan 2023 19:36:07 +0100 Subject: [PATCH] =?UTF-8?q?Cards.js=20erstellt=20+=20UnitTest=20-=20Konstr?= =?UTF-8?q?uktor=20Klasse=20Cards=20-=20Erstellen=20von=20normalen=20Karte?= =?UTF-8?q?n=20hinzugef=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- uno/index.html | 1 + uno/js/cards/Cards.js | 31 +++++++++++++++++++++++ uno/tests/test_Cards.test.js | 48 ++++++++++++++++++++++++++++++++++++ 3 files changed, 80 insertions(+) create mode 100644 uno/js/cards/Cards.js create mode 100644 uno/tests/test_Cards.test.js diff --git a/uno/index.html b/uno/index.html index 8192a22..d0977e9 100644 --- a/uno/index.html +++ b/uno/index.html @@ -6,5 +6,6 @@ + \ No newline at end of file diff --git a/uno/js/cards/Cards.js b/uno/js/cards/Cards.js new file mode 100644 index 0000000..755c52c --- /dev/null +++ b/uno/js/cards/Cards.js @@ -0,0 +1,31 @@ + +class Cards { + + constructor(name, color) { + + this._onScreen = false; + this._canPut = false; + this._name = name; + this._color = color; + + } + + get name() { + return this._name; + } + + get canPut() { + return this._canPut; + } + + get color() { + return this._color; + } + + get onScreen() { + return this._onScreen; + } + +} + +module.exports = Cards; \ No newline at end of file diff --git a/uno/tests/test_Cards.test.js b/uno/tests/test_Cards.test.js new file mode 100644 index 0000000..cc02c83 --- /dev/null +++ b/uno/tests/test_Cards.test.js @@ -0,0 +1,48 @@ +const uno = require('../js/uno'); +const Cards = require('../js/cards/Cards'); + +const CARD_COLORS = uno.CARD_COLORS; + +//Testet das Erstellen einer Karte +describe('Karten erstellen', () => { + + let card; + + it('6 - Blau', () => { + + //Erstellen einer normalen Karte: + // Name: 6, Farbe: Blau + card = new Cards('6', CARD_COLORS[1]); + + //Testet das Erstellen der Karte + testCreatedCard(card, '6', "BLUE"); + + }); + + it('8 - Grün', () => { + + //Erstellen einer normalen Karte: + // Name: 6, Farbe: Blau + card = new Cards('8', CARD_COLORS[2]); + + //Testet das Erstellen der Karte + testCreatedCard(card, '8', "GREEN"); + + }); + +}); + +function testCreatedCard(card, number, card_colors){ + + //Wenn Karte erstellt, wird Sie noch nicht auf dem Bildschirm abgebildet + expect(card.onScreen).toBe(false); + + //Wenn Karte erstellt, kann sie noch nicht gesetzt werden + expect(card.canPut).toBe(false); + + //Name der Karte muss der übergebene Name sein + expect(card.name).toBe(number); + + //Farbe der Karte muss die übergebene Farbe sein + expect(card.color).toBe(card_colors); +} \ No newline at end of file