OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * Copyright 2014 Google Inc. All rights reserved. |
| 3 * |
| 4 * Use of this source code is governed by a BSD-style |
| 5 * license that can be found in the LICENSE file or at |
| 6 * https://developers.google.com/open-source/licenses/bsd |
| 7 */ |
| 8 |
| 9 part of charted.test.svg; |
| 10 |
| 11 testSvgLine() { |
| 12 |
| 13 List mockSvgData = [ |
| 14 [1, 2], [2, 1.5], [4, 8], [4.5, 2], [10, 2], [11, 5], |
| 15 ]; |
| 16 |
| 17 group('SvgLine.xAccessor', () { |
| 18 SvgLine svgLine = new SvgLine(); |
| 19 test('is set to defaultDataToX by default', () { |
| 20 mockSvgData.forEach((e) => expect(svgLine.xAccessor(e, 0), equals(e[0]))); |
| 21 }); |
| 22 test('is set to a constant value as the x-value for all points', () { |
| 23 svgLine.x = 3; |
| 24 mockSvgData.forEach((e) => expect(svgLine.xAccessor(e, 0), equals(3))); |
| 25 }); |
| 26 }); |
| 27 |
| 28 group('SvgLine.yAccessor', () { |
| 29 SvgLine svgLine = new SvgLine(); |
| 30 test('is set to defaultDataToY by default', () { |
| 31 mockSvgData.forEach((e) => expect(svgLine.yAccessor(e, 0), equals(e[1]))); |
| 32 }); |
| 33 test('is set to a constant value as the y-value for all points', () { |
| 34 svgLine.y = 3; |
| 35 mockSvgData.forEach((e) => expect(svgLine.yAccessor(e, 0), equals(3))); |
| 36 }); |
| 37 }); |
| 38 |
| 39 group('SvgLine.path', () { |
| 40 SvgLine svgLine = new SvgLine(); |
| 41 test('generates one line path by default', () { |
| 42 expect(svgLine.path(mockSvgData, 0, null), |
| 43 equals('M1,2L2,1.5L4,8L4.5,2L10,2L11,5')); |
| 44 }); |
| 45 test('generates several line segments if some points are not valid', () { |
| 46 svgLine.defined = (d, i, e) => i != 3; // The fourth point is not valid. |
| 47 expect(svgLine.path(mockSvgData, 0, null), |
| 48 equals('M1,2L2,1.5L4,8M10,2L11,5')); |
| 49 svgLine.defined = (d, i, e) => i == 1; // Only the second point is valid. |
| 50 expect(svgLine.path(mockSvgData, 0, null), equals('M2,1.5')); |
| 51 }); |
| 52 }); |
| 53 |
| 54 } |
OLD | NEW |