提交 4c5d6a3c 编写于 作者: O Ovilia

add more test

上级 0dfb5f2a
......@@ -5,7 +5,7 @@
// canvas comparing strategy, 'stack' or 'content'
var STRATEGY = 'stack';
// always display images even if no error
var ALWAYS_SHOW_IMAGE = true;
var ALWAYS_SHOW_IMAGE = false;
// dom for failed cases
var failedDom = document.createElement('div');
......@@ -108,8 +108,11 @@
expect(compare1).not.toEqual(compare2);
}
if (ALWAYS_SHOW_IMAGE || img1 === img2 ^ isExpectEqual) {
if (ALWAYS_SHOW_IMAGE || (compare1 === compare2) ^ isExpectEqual) {
helper.addFailedCases(title, img1, img2);
console.log(title);
console.log(JSON.stringify(ctx1.stack()));
console.log(JSON.stringify(ctx2.stack()));
}
done();
......
......@@ -100,16 +100,86 @@ describe('title', function() {
option1: {
series: [],
title: {
text: 'compare padding with 5px and 20px'
text: 'should display one-value padding'
}
},
option2: {
series: [],
title: {
text: 'compare padding with 5px and 20px',
text: 'should display one-value padding',
padding: 50
}
}
}, {
name: 'should display two-value padding',
test: 'notEqualOption',
option1: {
series: [],
title: {
text: 'display two-value padding'
}
},
option2: {
series: [],
title: {
text: 'display two-value padding',
padding: [20, 50]
}
}
}, {
name: 'should display four-value padding',
test: 'notEqualOption',
option1: {
series: [],
title: {
text: 'compare padding with 10, 30, 50, 70'
}
},
option2: {
series: [],
title: {
text: 'compare padding with 10, 30, 50, 70',
padding: [10, 30, 50, 70]
}
}
}, {
name: 'should display four-value and two-value padding accordingly',
test: 'equalOption',
option1: {
series: [],
title: {
text: 'compare padding with 20, 50 and 20, 50, 20, 50',
padding: [20, 50]
}
},
option2: {
series: [],
title: {
text: 'compare padding with 20, 50 and 20, 50, 20, 50',
padding: [20, 50, 20, 50]
}
}
}]
}, {
name: 'itemGap',
cases: [{
name: 'should have default itemGap as 5px',
test: 'equalOption',
option1: {
series: [],
title: {
text: 'title',
subtext: 'subtext'
}
},
option2: {
series: [],
title: {
text: 'title',
subtext: 'subtext',
itemGap: 5
}
}
}]
}];
......
......@@ -95,20 +95,61 @@ describe('title.subtextStyle', function() {
}
}
}
}, {
name: 'should display italic not as normal',
test: 'notEqualOption',
option1: {
series: [],
title: {
subtext: 'italic vs. normal',
subtextStyle: {
fontStyle: 'italic'
}
}
},
option2: {
series: [],
title: {
subtext: 'italic vs. normal',
subtextStyle: {
fontStyle: 'normal'
}
}
}
}, {
name: 'should display oblique not as normal',
test: 'notEqualOption',
option1: {
series: [],
title: {
subtext: 'oblique vs. normal',
subtextStyle: {
fontStyle: 'oblique'
}
}
},
option2: {
series: [],
title: {
subtext: 'oblique vs. normal',
subtextStyle: {
fontStyle: 'normal'
}
}
}
}]
}, {
name: 'subtextStyle.fontWeight',
cases: [{
name: 'should display default normal font weight',
option: {
test: 'equalOption',
option1: {
series: [],
title: {
subtext: 'normal font'
}
}
}, {
name: 'should display normal font weight',
option: {
},
option2: {
series: [],
title: {
subtext: 'normal font',
......@@ -119,76 +160,153 @@ describe('title.subtextStyle', function() {
}
}, {
name: 'should display bold font weight',
option: {
test: 'notEqualOption',
option1: {
series: [],
title: {
subtext: 'bold font',
subtext: 'bold font vs. normal font',
subtextStyle: {
fontStyle: 'bold'
}
}
},
option2: {
series: [],
title: {
subtext: 'bold font vs. normal font',
subtextStyle: {
fontStyle: 'normal'
}
}
}
}, {
name: 'should display bolder font weight',
option: {
test: 'notEqualOption',
option1: {
series: [],
title: {
subtext: 'bolder font',
subtext: 'bolder font vs. normal font',
subtextStyle: {
fontStyle: 'bolder'
}
}
},
option2: {
series: [],
title: {
subtext: 'bolder font vs. normal font',
subtextStyle: {
fontStyle: 'normal'
}
}
}
}, {
name: 'should display lighter font weight',
option: {
name: 'should display light font weight',
test: 'notEqualOption',
option1: {
series: [],
title: {
subtext: 'lighter font',
subtext: 'light font vs. normal font',
subtextStyle: {
fontStyle: 'lighter'
fontStyle: 'light'
}
}
},
option2: {
series: [],
title: {
subtext: 'light font vs. normal font',
subtextStyle: {
fontStyle: 'normal'
}
}
}
}, {
name: 'should display font weight as number',
option: {
name: 'should display numbering font weight',
test: 'notEqualOption',
option1: {
series: [],
title: {
subtext: 'font weight at 100',
subtext: '100 font vs. normal font',
subtextStyle: {
fontStyle: '100'
}
}
},
option2: {
series: [],
title: {
subtext: '100 font vs. normal font',
subtextStyle: {
fontStyle: 'normal'
}
}
}
}]
}, {
name: 'subtextStyle.fontFamily',
cases: [{
name: 'should display default fontSize at 12',
option: {
name: 'should display default fontFamily as sans-serif',
test: 'equalOption',
option1: {
series: [],
title: {
subtext: 'sans-serif'
}
},
option2: {
series: [],
title: {
subtext: 'sans-serif',
fontFamily: 'sans-serif'
}
}
}, {
name: 'should display default fontFamily as Arial',
test: 'notEqualOption',
option1: {
series: [],
title: {
subtext: 'Arial vs. sans-serif',
subtextStyle: {
fontFamily: 'Arial'
}
}
},
option2: {
series: [],
title: {
subtext: 'default font size, should be 12',
subtext: 'Arial vs. sans-serif',
subtextStyle: {
fontSize: undefined
fontFamily: 'sans-serif'
}
}
}
}, {
name: 'should display normal fontSize',
option: {
}]
}, {
name: 'textStyle.fontSize',
cases: [{
name: 'should display default fontSize at 18',
test: 'equalOption',
option1: {
series: [],
title: {
subtext: 'font size at 12',
subtext: 'default font size, should be 18'
}
},
option2: {
series: [],
title: {
subtext: 'default font size, should be 18',
subtextStyle: {
fontSize: 12
fontSize: 18
}
}
}
}, {
name: 'should display larger fontSize',
option: {
test: 'notEqualOption',
option1: {
series: [],
title: {
subtext: 'larger font size, 30',
......@@ -196,15 +314,34 @@ describe('title.subtextStyle', function() {
fontSize: 30
}
}
},
option2: {
series: [],
title: {
subtext: 'larger font size, 30',
subtextStyle: {
fontSize: 18
}
}
}
}, {
name: 'should display smaller fontSize',
option: {
test: 'notEqualOption',
option1: {
series: [],
title: {
subtext: 'smaller font size, 12',
subtextStyle: {
fontSize: 12
}
}
},
option2: {
series: [],
title: {
subtext: 'smaller font size, 10',
subtext: 'smaller font size, 12',
subtextStyle: {
fontSize: 10
fontSize: 18
}
}
}
......
......@@ -95,20 +95,61 @@ describe('title.textStyle', function() {
}
}
}
}, {
name: 'should display italic not as normal',
test: 'notEqualOption',
option1: {
series: [],
title: {
text: 'italic vs. normal',
textStyle: {
fontStyle: 'italic'
}
}
},
option2: {
series: [],
title: {
text: 'italic vs. normal',
textStyle: {
fontStyle: 'normal'
}
}
}
}, {
name: 'should display oblique not as normal',
test: 'notEqualOption',
option1: {
series: [],
title: {
text: 'oblique vs. normal',
textStyle: {
fontStyle: 'oblique'
}
}
},
option2: {
series: [],
title: {
text: 'oblique vs. normal',
textStyle: {
fontStyle: 'normal'
}
}
}
}]
}, {
name: 'textStyle.fontWeight',
cases: [{
name: 'should display default normal font weight',
option: {
test: 'equalOption',
option1: {
series: [],
title: {
text: 'normal font'
}
}
}, {
name: 'should display normal font weight',
option: {
},
option2: {
series: [],
title: {
text: 'normal font',
......@@ -119,101 +160,142 @@ describe('title.textStyle', function() {
}
}, {
name: 'should display bold font weight',
option: {
test: 'notEqualOption',
option1: {
series: [],
title: {
text: 'bold font',
text: 'bold font vs. normal font',
textStyle: {
fontStyle: 'bold'
}
}
},
option2: {
series: [],
title: {
text: 'bold font vs. normal font',
textStyle: {
fontStyle: 'normal'
}
}
}
}, {
name: 'should display bolder font weight',
option: {
test: 'notEqualOption',
option1: {
series: [],
title: {
text: 'bolder font',
text: 'bolder font vs. normal font',
textStyle: {
fontStyle: 'bolder'
}
}
},
option2: {
series: [],
title: {
text: 'bolder font vs. normal font',
textStyle: {
fontStyle: 'normal'
}
}
}
}, {
name: 'should display lighter font weight',
option: {
name: 'should display light font weight',
test: 'notEqualOption',
option1: {
series: [],
title: {
text: 'lighter font',
text: 'light font vs. normal font',
textStyle: {
fontStyle: 'lighter'
fontStyle: 'light'
}
}
},
option2: {
series: [],
title: {
text: 'light font vs. normal font',
textStyle: {
fontStyle: 'normal'
}
}
}
}, {
name: 'should display font weight as number',
option: {
name: 'should display numbering font weight',
test: 'notEqualOption',
option1: {
series: [],
title: {
text: 'font weight at 100',
text: '100 font vs. normal font',
textStyle: {
fontStyle: '100'
}
}
},
option2: {
series: [],
title: {
text: '100 font vs. normal font',
textStyle: {
fontStyle: 'normal'
}
}
}
}]
}, {
name: 'textStyle.fontFamily',
cases: [{
name: 'should display default fontFamily as sans-serif',
option: {
test: 'equalOption',
option1: {
series: [],
title: {
text: 'sans-serif',
textStyle: {
fontFamily: undefined
}
text: 'sans-serif'
}
}
}, {
name: 'should display fontFamily as sans-serif',
option: {
},
option2: {
series: [],
title: {
text: 'sans-serif',
textStyle: {
fontFamily: 'sans-serif'
}
fontFamily: 'sans-serif'
}
}
}, {
name: 'should display default fontFamily as Arial',
option: {
test: 'notEqualOption',
option1: {
series: [],
title: {
text: 'Arial',
text: 'Arial vs. sans-serif',
textStyle: {
fontFamily: 'Arial'
}
}
},
option2: {
series: [],
title: {
text: 'Arial vs. sans-serif',
fontFamily: 'sans-serif'
}
}
}]
}, {
name: 'textStyle.fontSize',
cases: [{
name: 'should display default fontSize at 18',
option: {
test: 'equalOption',
option1: {
series: [],
title: {
text: 'default font size, should be 18'
}
}
}, {
name: 'should display normal fontSize',
option: {
},
option2: {
series: [],
title: {
text: 'font size at 18',
text: 'default font size, should be 18',
textStyle: {
fontSize: 18
}
......@@ -221,7 +303,8 @@ describe('title.textStyle', function() {
}
}, {
name: 'should display larger fontSize',
option: {
test: 'notEqualOption',
option1: {
series: [],
title: {
text: 'larger font size, 30',
......@@ -229,10 +312,20 @@ describe('title.textStyle', function() {
fontSize: 30
}
}
},
option2: {
series: [],
title: {
text: 'larger font size, 30',
textStyle: {
fontSize: 18
}
}
}
}, {
name: 'should display smaller fontSize',
option: {
test: 'notEqualOption',
option1: {
series: [],
title: {
text: 'smaller font size, 12',
......@@ -240,6 +333,15 @@ describe('title.textStyle', function() {
fontSize: 12
}
}
},
option2: {
series: [],
title: {
text: 'smaller font size, 12',
textStyle: {
fontSize: 18
}
}
}
}]
}];
......
......@@ -30,8 +30,8 @@
<script src="core/uiHelper.js"></script>
<script src="spec/ui/title.js"></script>
<!-- <script src="spec/ui/title.subtextStyle.js"></script> -->
<!-- <script src="spec/ui/title.textStyle.js"></script> -->
<script src="spec/ui/title.subtextStyle.js"></script>
<script src="spec/ui/title.textStyle.js"></script>
</head>
<body>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册