test/card/cardParameterized.js   A
last analyzed

Complexity

Total Complexity 7
Complexity/F 1

Size

Lines of Code 58
Function Count 7

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 0
c 2
b 0
f 0
nc 1
dl 0
loc 58
rs 10
wmc 7
mnd 0
bc 7
fnc 7
bpm 1
cpm 1
noi 0

3 Functions

Rating   Name   Duplication   Size   Complexity  
A cardParameterized.js ➔ checkCard 0 6 1
A cardParameterized.js ➔ checkRank 0 6 1
A cardParameterized.js ➔ describe(ꞌCheck card ranksꞌ) 0 22 1
1
/**
2
* Test for class Card, parameterized version of testsuite.
3
 */
4
"use strict";
5
6
/* global describe it */
7
8
var assert = require("assert");
9
const Card = require("../../src/card/card");
10
11
12
13
/**
14
 * Check a card with its expected card face.
15
 */
16
function checkCard(id, expected) {
17
    let card = new Card();
18
    let res = card.getCard(id);
19
20
    assert.equal(res, expected);
21
}
22
23
24
25
/**
26
 * Check the card rank.
27
 */
28
function checkRank(id, expected) {
29
    let card = new Card();
30
    let res = card.getRank(id);
31
32
    assert.equal(res, expected);
33
}
34
35
36
37
/**
38
 * Testsuite
39
 */
40
describe("Check card ranks", function() {
41
    var tests = [
42
        {id: 0,  face: "♣A", rank: 14},
43
        {id: 1,  face: "♣2", rank: 2},
44
        {id: 13, face: "♦A", rank: 14},
45
        {id: 26, face: "♠A", rank: 14},
46
        {id: 39, face: "♥A", rank: 14},
47
        {id: 51, face: "♥K", rank: 13},
48
        {id: 52, face: undefined, rank: undefined},
49
    ];
50
51
    tests.forEach(function(test) {
52
        describe("Get card with value " + test.id, function() {
53
            it("should be card " + test.face, function () {
54
                checkCard(test.id, test.face);
55
            });
56
            it("should have rank " + test.rank, function () {
57
                checkRank(test.id, test.rank);
58
            });
59
        });
60
    });
61
});
62