Skip to content

Commit

Permalink
Initial tests for LineChartView
Browse files Browse the repository at this point in the history
  • Loading branch information
yas375 committed Sep 27, 2015
1 parent 33812e4 commit f44e4e1
Show file tree
Hide file tree
Showing 7 changed files with 81 additions and 0 deletions.
12 changes: 12 additions & 0 deletions ChartsDemo/ChartsDemo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
objects = {

/* Begin PBXBuildFile section */
50392B241BB7366C002235E5 /* LineChartViewSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50392B231BB7366C002235E5 /* LineChartViewSpec.swift */; settings = {ASSET_TAGS = (); }; };
55E356501ADC638F00A57971 /* BubbleChartViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 55E3564D1ADC638F00A57971 /* BubbleChartViewController.xib */; };
55E356511ADC638F00A57971 /* BubbleChartViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 55E3564F1ADC638F00A57971 /* BubbleChartViewController.m */; };
5B0CC7851ABB875400665592 /* PieChartViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 5B0CC7831ABB875400665592 /* PieChartViewController.m */; };
Expand Down Expand Up @@ -107,6 +108,7 @@
/* End PBXCopyFilesBuildPhase section */

/* Begin PBXFileReference section */
50392B231BB7366C002235E5 /* LineChartViewSpec.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LineChartViewSpec.swift; sourceTree = "<group>"; };
5054F01C1BB72FE50038506D /* ChartsTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = ChartsTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
5054F0201BB72FE50038506D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
55E3564D1ADC638F00A57971 /* BubbleChartViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = BubbleChartViewController.xib; sourceTree = "<group>"; };
Expand Down Expand Up @@ -233,9 +235,18 @@
name = Pods;
sourceTree = "<group>";
};
50392B221BB7366C002235E5 /* Charts */ = {
isa = PBXGroup;
children = (
50392B231BB7366C002235E5 /* LineChartViewSpec.swift */,
);
path = Charts;
sourceTree = "<group>";
};
5054F01D1BB72FE50038506D /* ChartsTests */ = {
isa = PBXGroup;
children = (
50392B221BB7366C002235E5 /* Charts */,
5054F0201BB72FE50038506D /* Info.plist */,
);
path = ChartsTests;
Expand Down Expand Up @@ -605,6 +616,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
50392B241BB7366C002235E5 /* LineChartViewSpec.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
69 changes: 69 additions & 0 deletions ChartsDemo/ChartsTests/Charts/LineChartViewSpec.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
//
// LineChartViewSpec.swift
// ChartsDemo
//
// Created by Victor Ilyukevich on 9/26/15.
// Copyright © 2015 dcg. All rights reserved.
//

import Quick
import Nimble
import Nimble_Snapshots
import UIKit
import Charts

class LineChartViewSpec: QuickSpec {
override func spec() {
describe("line chart", {
context("with positive values", {
var chartView: LineChartView!

beforeEach({
// Sample data
let values: [Double] = [8, 104, 81, 93, 52, 44, 97, 101, 75, 28,
76, 25, 20, 13, 52, 44, 57, 23, 45, 91,
99, 14, 84, 48, 40, 71, 106, 41, 45, 61]

var entries: [ChartDataEntry] = Array()
var xValues: [String] = Array()

for (i, value) in values.enumerate() {
entries.append(ChartDataEntry.init(value: value, xIndex: i))
xValues.append("\(i)")
}

let dataSet = LineChartDataSet.init(yVals: entries, label: "First unit test data")
let data = LineChartData.init(xVals: xValues, dataSet: dataSet)

chartView = LineChartView.init(frame: CGRectMake(0, 0, 480, 350))
chartView.data = data
})

it("is with default values") {
expect(chartView).to(haveValidSnapshot())
}

it("hides values") {
chartView.data?.dataSets.first?.drawValuesEnabled = false
expect(chartView).to(haveValidSnapshot())
}

it("is filled") {
chartView.data?.dataSets.first?.drawValuesEnabled = true
expect(chartView).to(haveValidSnapshot())
}

it("does not draw circles") {
(chartView.data?.dataSets.first as! LineChartDataSet).drawCirclesEnabled = false
expect(chartView).to(haveValidSnapshot())
}

it("is cubic") {
(chartView.data?.dataSets.first as! LineChartDataSet).drawCubicEnabled = true
expect(chartView).to(haveValidSnapshot())
}

})
});
}
}
Binary file added ...ineChartViewSpec/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added ...eImages/LineChartViewSpec/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added ...neChartViewSpec/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit f44e4e1

Please sign in to comment.