forked from 3lvis/Form
-
Notifications
You must be signed in to change notification settings - Fork 9
/
FORMTextFieldCellTests.m
executable file
·50 lines (36 loc) · 1.34 KB
/
FORMTextFieldCellTests.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
@import UIKit;
@import XCTest;
#import "FORMTextFieldCell.h"
@interface FORMTextFieldCell (Tests)
- (CGRect)labelFrameUsingString:(NSString *)string;
- (NSString *)rawTextForField:(FORMField *)field;
@end
@interface FORMTextFormFieldCellTests : XCTestCase
@end
@implementation FORMTextFormFieldCellTests
- (void)testWidthCalculation {
FORMTextFieldCell *cell = [FORMTextFieldCell new];
CGRect rect = [cell labelFrameUsingString:@"bork"];
XCTAssertEqual(rect.size.width, 90.0f);
XCTAssertEqual(rect.size.height, 55.0f);
rect = [cell labelFrameUsingString:@"bork\nbork\nboork"];
XCTAssertEqual(rect.size.width, 90.0f);
XCTAssertEqual(rect.size.height, 77.0f);
rect = [cell labelFrameUsingString:@"bork\nborkborkborkbork\nboork"];
XCTAssertEqual(rect.size.width, 128.0f);
XCTAssertEqual(rect.size.height, 77.0f);
}
- (void)testRawTextForField {
FORMTextFieldCell *cell = [FORMTextFieldCell new];
FORMField *field = [FORMField new];
field.value = @1;
field.type = FORMFieldTypeNumber;
XCTAssertEqualObjects([cell rawTextForField:field], @"1");
field.value = @1.1;
field.type = FORMFieldTypeFloat;
XCTAssertEqualObjects([cell rawTextForField:field], @"1.10");
field.value = @"1";
field.type = FORMFieldTypeText;
XCTAssertEqualObjects([cell rawTextForField:field], @"1");
}
@end