Add: HistoryRecordManager
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width">
|
||||
<title>QUnit Example</title>
|
||||
<link rel="stylesheet" href="https://code.jquery.com/qunit/qunit-2.6.0.css">
|
||||
</head>
|
||||
<body>
|
||||
<div id="qunit"></div>
|
||||
<div id="qunit-fixture"></div>
|
||||
<script src="https://code.jquery.com/qunit/qunit-2.6.0.js"></script>
|
||||
<script src="../src/game/lib/number_util.js"></script>
|
||||
<script src="../src/game/lib/history_record_manager.js"></script>
|
||||
<script src="test_history_record_manager.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,16 +1,16 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width">
|
||||
<title>QUnit Example</title>
|
||||
<link rel="stylesheet" href="https://code.jquery.com/qunit/qunit-2.6.0.css">
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width">
|
||||
<title>QUnit Example</title>
|
||||
<link rel="stylesheet" href="https://code.jquery.com/qunit/qunit-2.6.0.css">
|
||||
</head>
|
||||
<body>
|
||||
<div id="qunit"></div>
|
||||
<div id="qunit-fixture"></div>
|
||||
<script src="https://code.jquery.com/qunit/qunit-2.6.0.js"></script>
|
||||
<script src="../src/game/lib/number_util.js"></script>
|
||||
<script src="test_number_util.js"></script>
|
||||
<div id="qunit"></div>
|
||||
<div id="qunit-fixture"></div>
|
||||
<script src="https://code.jquery.com/qunit/qunit-2.6.0.js"></script>
|
||||
<script src="../src/game/lib/number_util.js"></script>
|
||||
<script src="test_number_util.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,32 @@
|
||||
let historyRecordManager = new HistoryRecordManager();
|
||||
|
||||
historyRecordManager.push(new HistoryRecordData("05/10", 1000));
|
||||
historyRecordManager.push(new HistoryRecordData("05/11", 100));
|
||||
historyRecordManager.push(new HistoryRecordData("05/12", 200));
|
||||
historyRecordManager.push(new HistoryRecordData("05/13", 2000));
|
||||
historyRecordManager.push(new HistoryRecordData("05/14", 10000));
|
||||
|
||||
QUnit.test( "push", function( assert ) {
|
||||
assert.equal(historyRecordManager.count, 5);
|
||||
});
|
||||
|
||||
QUnit.test( "getAt", function( assert ) {
|
||||
assert.equal(historyRecordManager.getDateAt(0), "05/10");
|
||||
assert.equal(historyRecordManager.getDateAt(4), "05/14");
|
||||
});
|
||||
|
||||
QUnit.test( "clear", function( assert ) {
|
||||
let historyRecordManagerForClear = new HistoryRecordManager();
|
||||
historyRecordManagerForClear.push(new HistoryRecordData("05/10", 1));
|
||||
historyRecordManagerForClear.clear();
|
||||
|
||||
assert.equal(historyRecordManagerForClear.count, 0);
|
||||
});
|
||||
|
||||
QUnit.test( "underValueForGraph", function( assert ) {
|
||||
assert.equal(historyRecordManager.underValueForGraph(), 100);
|
||||
});
|
||||
|
||||
QUnit.test( "upperValueForGraph", function( assert ) {
|
||||
assert.equal(historyRecordManager.upperValueForGraph(), 10000);
|
||||
});
|
||||
@@ -3,4 +3,15 @@ QUnit.test( "NumberWithCommas", function( assert ) {
|
||||
assert.equal(NumberUtil.numberWithCommas(1000), "1,000", "NumberWithCommas");
|
||||
assert.equal(NumberUtil.numberWithCommas(100000), "100,000", "NumberWithCommas");
|
||||
assert.equal(NumberUtil.numberWithCommas(1000000), "1,000,000", "NumberWithCommas");
|
||||
});
|
||||
|
||||
QUnit.test( "NumberOfDigits", function( assert ) {
|
||||
assert.equal(NumberUtil.numberOfDigits(1), 1);
|
||||
assert.equal(NumberUtil.numberOfDigits(10), 2);
|
||||
assert.equal(NumberUtil.numberOfDigits(100), 3);
|
||||
assert.equal(NumberUtil.numberOfDigits(999), 3);
|
||||
assert.equal(NumberUtil.numberOfDigits(1000), 4);
|
||||
assert.equal(NumberUtil.numberOfDigits(9999), 4);
|
||||
assert.equal(NumberUtil.numberOfDigits(10000), 5);
|
||||
assert.equal(NumberUtil.numberOfDigits(99999), 5);
|
||||
});
|
||||
Reference in New Issue
Block a user