Skip to content

Commit ecd3875

Browse files
committed
Fix tests
1 parent 903d4a9 commit ecd3875

5 files changed

Lines changed: 39 additions & 14 deletions

File tree

dist/CommentCoreLibrary.js

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1660,8 +1660,10 @@ var AcfunFormat = (function () {
16601660

16611661
AcfunFormat.JSONParser = function (params) {
16621662
this._logBadComments = true;
1663+
this._logNotImplemented = false;
16631664
if (typeof params === 'object') {
16641665
this._logBadComments = params.logBadComments === false ? false : true;
1666+
this._logNotImplemented = params.logNotImplemented === true ? true : false;
16651667
}
16661668
};
16671669

@@ -1719,7 +1721,9 @@ var AcfunFormat = (function () {
17191721
case 6: data.align = 2; break;
17201722
case 8: data.align = 3; break;
17211723
default:
1722-
console.log('Cannot handle aligning to center! AlignMode=' + x.c);
1724+
if (this._logNotImplemented) {
1725+
console.log('Cannot handle aligning to center! AlignMode=' + x.c);
1726+
}
17231727
}
17241728
}
17251729
// Use default axis
@@ -1745,15 +1749,21 @@ var AcfunFormat = (function () {
17451749
var motion = {};
17461750
if (x.z[m].hasOwnProperty('rx') && typeof x.z[m].rx === 'number') {
17471751
// TODO: Support this
1748-
console.log('Encountered animated x-axis rotation. Ignoring.');
1752+
if (this._logNotImplemented) {
1753+
console.log('Encountered animated x-axis rotation. Ignoring.');
1754+
}
17491755
}
17501756
if (x.z[m].hasOwnProperty('e') && typeof x.z[m].e === 'number') {
17511757
// TODO: Support this
1752-
console.log('Encountered animated y-axis rotation. Ignoring.');
1758+
if (this._logNotImplemented) {
1759+
console.log('Encountered animated y-axis rotation. Ignoring.');
1760+
}
17531761
}
17541762
if (x.z[m].hasOwnProperty('d') && typeof x.z[m].d === 'number') {
17551763
// TODO: Support this
1756-
console.log('Encountered animated z-axis rotation. Ignoring.');
1764+
if (this._logNotImplemented) {
1765+
console.log('Encountered animated z-axis rotation. Ignoring.');
1766+
}
17571767
}
17581768
if (x.z[m].hasOwnProperty('x') && typeof x.z[m].x === 'number') {
17591769
motion.x = {
@@ -1806,8 +1816,10 @@ var AcfunFormat = (function () {
18061816
if (x.w.hasOwnProperty('l') && Array.isArray(x.w.l)) {
18071817
if (x.w.l.length > 0) {
18081818
// Filters
1809-
console.log('[Dbg] Filters not supported! ' +
1810-
JSON.stringify(x.w.l));
1819+
if (this._logNotImplemented) {
1820+
console.log('[Dbg] Filters not supported! ' +
1821+
JSON.stringify(x.w.l));
1822+
}
18111823
}
18121824
}
18131825
}

dist/CommentCoreLibrary.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

spec/CommentCoreLibrary_spec.coffee

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ describe 'CommentManager', ->
5858
# TODO: Construct a json that cover all types of comments
5959
# and use it for smoking test
6060
manager.load comments
61-
expect(manager.timeline.length).toBe 1962
61+
expect(manager.timeline.length).toBe 2146
6262

6363
describe '.send', ->
6464
it 'sends to runline' , ->

spec/CommentProvider_spec.coffee

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ describe 'CommentProvider', ->
77
# Don't actually call f
88
window.Promise.prototype.then = (f) -> this
99
window.Promise.prototype.catch = (f) -> this
10+
window.Promise.resolve = (f) -> new Promise()
1011

1112
it 'has constants', ->
1213
expect(CommentProvider.SOURCE_XML).toBe 'XML'

src/parsers/AcfunFormat.js

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@ var AcfunFormat = (function () {
88

99
AcfunFormat.JSONParser = function (params) {
1010
this._logBadComments = true;
11+
this._logNotImplemented = false;
1112
if (typeof params === 'object') {
1213
this._logBadComments = params.logBadComments === false ? false : true;
14+
this._logNotImplemented = params.logNotImplemented === true ? true : false;
1315
}
1416
};
1517

@@ -67,7 +69,9 @@ var AcfunFormat = (function () {
6769
case 6: data.align = 2; break;
6870
case 8: data.align = 3; break;
6971
default:
70-
console.log('Cannot handle aligning to center! AlignMode=' + x.c);
72+
if (this._logNotImplemented) {
73+
console.log('Cannot handle aligning to center! AlignMode=' + x.c);
74+
}
7175
}
7276
}
7377
// Use default axis
@@ -93,15 +97,21 @@ var AcfunFormat = (function () {
9397
var motion = {};
9498
if (x.z[m].hasOwnProperty('rx') && typeof x.z[m].rx === 'number') {
9599
// TODO: Support this
96-
console.log('Encountered animated x-axis rotation. Ignoring.');
100+
if (this._logNotImplemented) {
101+
console.log('Encountered animated x-axis rotation. Ignoring.');
102+
}
97103
}
98104
if (x.z[m].hasOwnProperty('e') && typeof x.z[m].e === 'number') {
99105
// TODO: Support this
100-
console.log('Encountered animated y-axis rotation. Ignoring.');
106+
if (this._logNotImplemented) {
107+
console.log('Encountered animated y-axis rotation. Ignoring.');
108+
}
101109
}
102110
if (x.z[m].hasOwnProperty('d') && typeof x.z[m].d === 'number') {
103111
// TODO: Support this
104-
console.log('Encountered animated z-axis rotation. Ignoring.');
112+
if (this._logNotImplemented) {
113+
console.log('Encountered animated z-axis rotation. Ignoring.');
114+
}
105115
}
106116
if (x.z[m].hasOwnProperty('x') && typeof x.z[m].x === 'number') {
107117
motion.x = {
@@ -154,8 +164,10 @@ var AcfunFormat = (function () {
154164
if (x.w.hasOwnProperty('l') && Array.isArray(x.w.l)) {
155165
if (x.w.l.length > 0) {
156166
// Filters
157-
console.log('[Dbg] Filters not supported! ' +
158-
JSON.stringify(x.w.l));
167+
if (this._logNotImplemented) {
168+
console.log('[Dbg] Filters not supported! ' +
169+
JSON.stringify(x.w.l));
170+
}
159171
}
160172
}
161173
}

0 commit comments

Comments
 (0)