|
| 1 | +import XCTest |
| 2 | +import FBSnapshotTestCase |
| 3 | +@testable import Charts |
| 4 | + |
| 5 | +class BarChartTests: FBSnapshotTestCase |
| 6 | +{ |
| 7 | + |
| 8 | + var chart: BarChartView! |
| 9 | + var dataSet: BarChartDataSet! |
| 10 | + |
| 11 | + override func setUp() |
| 12 | + { |
| 13 | + super.setUp() |
| 14 | + |
| 15 | + // Set to `true` to re-capture all snapshots |
| 16 | + self.recordMode = false |
| 17 | + |
| 18 | + // Sample data |
| 19 | + let values: [Double] = [8, 104, 81, 93, 52, 44, 97, 101, 75, 28, |
| 20 | + 76, 25, 20, 13, 52, 44, 57, 23, 45, 91, |
| 21 | + 99, 14, 84, 48, 40, 71, 106, 41, 45, 61] |
| 22 | + |
| 23 | + var entries: [ChartDataEntry] = Array() |
| 24 | + var xValues: [String] = Array() |
| 25 | + |
| 26 | + for (i, value) in values.enumerate() |
| 27 | + { |
| 28 | + entries.append(BarChartDataEntry.init(value: value, xIndex: i)) |
| 29 | + xValues.append("\(i)") |
| 30 | + } |
| 31 | + |
| 32 | + dataSet = BarChartDataSet(yVals: entries, label: "Bar chart unit test data") |
| 33 | + |
| 34 | + chart = BarChartView(frame: CGRectMake(0, 0, 480, 350)) |
| 35 | + chart.data = BarChartData(xVals: xValues, dataSet: dataSet) |
| 36 | + } |
| 37 | + |
| 38 | + override func tearDown() |
| 39 | + { |
| 40 | + // Put teardown code here. This method is called after the invocation of each test method in the class. |
| 41 | + super.tearDown() |
| 42 | + } |
| 43 | + |
| 44 | + func testDefaultValues() |
| 45 | + { |
| 46 | + FBSnapshotVerifyView(chart) |
| 47 | + } |
| 48 | + |
| 49 | + func testHidesValues() |
| 50 | + { |
| 51 | + dataSet.drawValuesEnabled = false |
| 52 | + FBSnapshotVerifyView(chart) |
| 53 | + } |
| 54 | + |
| 55 | + func testHideLeftAxis() |
| 56 | + { |
| 57 | + chart.leftAxis.drawAxisLineEnabled = false |
| 58 | + FBSnapshotVerifyView(chart) |
| 59 | + } |
| 60 | + |
| 61 | + func testHideRightAxis() |
| 62 | + { |
| 63 | + chart.rightAxis.drawAxisLineEnabled = false |
| 64 | + FBSnapshotVerifyView(chart) |
| 65 | + } |
| 66 | + |
| 67 | + func testHideLeftAxisGridlines() |
| 68 | + { |
| 69 | + chart.leftAxis.drawGridLinesEnabled = false |
| 70 | + FBSnapshotVerifyView(chart) |
| 71 | + } |
| 72 | + |
| 73 | + func testHideRightAxisGridlines() |
| 74 | + { |
| 75 | + chart.rightAxis.drawGridLinesEnabled = false |
| 76 | + FBSnapshotVerifyView(chart) |
| 77 | + } |
| 78 | +} |
0 commit comments