Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
c3-closed
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Evgeny
c3-closed
Commits
f1e720e5
Commit
f1e720e5
authored
Sep 21, 2014
by
Masayuki Tanaka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add specs for legend - #515
parent
ea05aad7
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
95 additions
and
13 deletions
+95
-13
Gruntfile.coffee
Gruntfile.coffee
+3
-1
c3-helper.js
spec/c3-helper.js
+11
-0
c3-spec.js
spec/c3-spec.js
+7
-12
core-spec.js
spec/core-spec.js
+42
-0
legend-spec.js
spec/legend-spec.js
+32
-0
No files found.
Gruntfile.coffee
View file @
f1e720e5
...
@@ -83,7 +83,9 @@ module.exports = (grunt) ->
...
@@ -83,7 +83,9 @@ module.exports = (grunt) ->
c3
:
c3
:
src
:
'c3.js'
src
:
'c3.js'
options
:
options
:
specs
:
'spec/*.js'
specs
:
'spec/*-spec.js'
helpers
:
'spec/*-helper.js'
vendor
:
'http://d3js.org/d3.v3.min.js'
uglify
:
uglify
:
c3
:
c3
:
...
...
spec/c3-helper.js
0 → 100644
View file @
f1e720e5
function
initDom
()
{
'use strict'
;
var
div
=
document
.
createElement
(
'div'
);
div
.
id
=
'chart'
;
div
.
style
.
width
=
'640px'
;
div
.
style
.
height
=
'480px'
;
document
.
body
.
appendChild
(
div
);
document
.
body
.
style
.
margin
=
'0px'
;
}
typeof
initDom
!==
'undefined'
;
spec/c3-spec.js
View file @
f1e720e5
var
describe
=
window
.
describe
,
var
describe
=
window
.
describe
;
expect
=
window
.
expect
,
var
expect
=
window
.
expect
;
it
=
window
.
it
;
var
it
=
window
.
it
;
var
c3
=
window
.
c3
;
describe
(
'c3'
,
function
()
{
describe
(
'c3'
,
function
()
{
'use strict'
;
'use strict'
;
it
(
'exists'
,
function
()
{
var
c3
=
window
.
c3
;
expect
(
c3
).
not
.
toBe
(
null
);
it
(
'exists'
,
function
()
{
expect
(
c3
).
not
.
toBeNull
();
expect
(
typeof
c3
).
toBe
(
'object'
);
expect
(
typeof
c3
).
toBe
(
'object'
);
});
});
// ...write other tests here
});
});
spec/core-spec.js
0 → 100644
View file @
f1e720e5
var
describe
=
window
.
describe
,
expect
=
window
.
expect
,
it
=
window
.
it
,
beforeEach
=
window
.
beforeEach
;
describe
(
'c3 chart'
,
function
()
{
'use strict'
;
var
chart
,
d3
;
beforeEach
(
function
()
{
window
.
initDom
();
chart
=
window
.
c3
.
generate
({
data
:
{
columns
:
[
[
'data1'
,
30
,
200
,
100
,
400
,
150
,
250
],
[
'data2'
,
50
,
20
,
10
,
40
,
15
,
25
],
[
'data3'
,
150
,
120
,
110
,
140
,
115
,
125
]
]
}
});
d3
=
chart
.
internal
.
d3
;
});
it
(
'should be created'
,
function
()
{
var
svg
=
d3
.
select
(
'#chart svg'
);
expect
(
svg
).
not
.
toBeNull
();
});
it
(
'should have same width'
,
function
()
{
var
svg
=
d3
.
select
(
'#chart svg'
);
expect
(
+
svg
.
attr
(
'width'
)).
toBe
(
640
);
});
it
(
'should have same height'
,
function
()
{
var
svg
=
d3
.
select
(
'#chart svg'
);
expect
(
+
svg
.
attr
(
'height'
)).
toBe
(
480
);
});
});
spec/legend-spec.js
0 → 100644
View file @
f1e720e5
var
describe
=
window
.
describe
,
expect
=
window
.
expect
,
it
=
window
.
it
,
beforeEach
=
window
.
beforeEach
;
describe
(
'c3 chart legend'
,
function
()
{
'use strict'
;
var
chart
,
d3
;
beforeEach
(
function
()
{
window
.
initDom
();
chart
=
window
.
c3
.
generate
({
data
:
{
columns
:
[
[
'data1'
,
30
,
200
,
100
,
400
,
150
,
250
],
[
'data2'
,
50
,
20
,
10
,
40
,
15
,
25
],
[
'data3'
,
150
,
120
,
110
,
140
,
115
,
125
]
]
}
});
d3
=
chart
.
internal
.
d3
;
});
it
(
'should be located on the center of chart'
,
function
()
{
var
box
=
chart
.
internal
.
legend
.
node
().
getBoundingClientRect
();
expect
(
box
.
left
+
box
.
right
).
toBe
(
640
);
});
});
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment