-
Notifications
You must be signed in to change notification settings - Fork 20
/
test_cards.js
64 lines (55 loc) · 1.61 KB
/
test_cards.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/*
* test_card.js
* Test for the Card class
* Test case for Google-JS-Test http://code.google.com/p/google-js-test/
* command: gjstest --js_files=card.js,test_cards.js,deck.js,test_deck.js
*/
var localStorage = new Object();
localStorage.removeItem = function (key) {
delete this[key];
}
var c = new Card({'key':'cf'});
c.phrase1 = 'Chris';
c.phrase2 = 'Fattarsi';
c.save();
function CardTest() {}
registerTestSuite(CardTest);
CardTest.prototype.InitCard = function() {
var card = new Card();
//Assert new card fields are empty
expectNe('', card.key);
expectEq('', card.phrase1);
expectEq('',card.phrase2);
expectEq(0, card.points);
var card = new Card({'key':'abcd'});
expectEq('abcd', card.key);
expectEq('', card.phrase1);
expectEq('',card.phrase2);
expectEq(0, card.points);
var card = new Card({'key':'efg','phrase1':'hello','phrase2':'hola'});
expectEq('efg', card.key);
expectEq('hello', card.phrase1);
expectEq('hola',card.phrase2);
expectEq(0, card.points);
}
CardTest.prototype.CardOps = function() {
//open existing card, modify, save, and re-open
var card = new Card({'key':'cf'});
expectEq('cf', card.key);
expectEq('Chris', card.phrase1);
expectEq('Fattarsi',card.phrase2);
expectEq(0, card.points);
card.pointUp();
expectEq(1, card.points);
card.pointDown();
card.pointDown();
expectEq(-1, card.points);
card.phrase1 = 'John';
card.phrase2 = 'Doe';
card.save();
var card = new Card({'key':'cf'});
expectEq('cf', card.key);
expectEq('John', card.phrase1);
expectEq('Doe',card.phrase2);
expectEq(-1, card.points);
}