summaryrefslogtreecommitdiff
path: root/SmartDeviceLinkTests/DevAPISpecs/SDLMenuCellSpec.m
blob: fd4349887616229bcddcf00bda61d4678defad04 (plain)
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
#import <Quick/Quick.h>
#import <Nimble/Nimble.h>

#import "SDLArtwork.h"
#import "SDLMenuCell.h"

QuickSpecBegin(SDLMenuCellSpec)

describe(@"a menu cell", ^{
    __block SDLMenuCell *testCell = nil;
    __block SDLMenuCell *testCell2 = nil;
    __block SDLMenuLayout testLayout = SDLMenuLayoutList;
    __block NSString *someTitle = nil;
    __block NSString *someSecondaryTitle = nil;
    __block NSString *someTertiaryTitle = nil;
    __block SDLArtwork *someArtwork = nil;
    __block SDLArtwork *someSecondaryArtwork = nil;

    beforeEach(^{
        someTitle = @"Some Title";
        someSecondaryTitle = @"Some Title 2";
        someTertiaryTitle = @"Some Title 3";
        someArtwork = [[SDLArtwork alloc] initWithData:[[NSData alloc] initWithBase64EncodedString:@"data" options:kNilOptions] name:@"Some artwork" fileExtension:@"png" persistent:NO];
        someSecondaryArtwork = [[SDLArtwork alloc] initWithData:[[NSData alloc] initWithBase64EncodedString:@"data" options:kNilOptions] name:@"Some artwork 2" fileExtension:@"png" persistent:NO];
    });

    describe(@"initializing", ^{
        __block NSArray<NSString *> *someVoiceCommands = nil;
        __block NSArray<SDLMenuCell *> *someSubcells = nil;

        beforeEach(^{
            someVoiceCommands = @[@"some command"];

            SDLMenuCell *subcell = [[SDLMenuCell alloc] initWithTitle:@"Hello" secondaryText:nil tertiaryText:nil icon:nil secondaryArtwork:nil voiceCommands:nil handler:^(SDLTriggerSource  _Nonnull triggerSource) {}];
            someSubcells = @[subcell];
        });

        it(@"should set initWithTitle:icon:submenuLayout:subCells: propertly", ^{
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
            testCell = [[SDLMenuCell alloc] initWithTitle:someTitle icon:someArtwork submenuLayout:testLayout subCells:someSubcells];
#pragma clang diagnostic pop

            expect(testCell.title).to(equal(someTitle));
            expect(testCell.icon).to(equal(someArtwork));
            expect(testCell.voiceCommands).to(beNil());
            expect(testCell.subCells).to(equal(someSubcells));
            expect(testCell.secondaryText).to(beNil());
            expect(testCell.tertiaryText).to(beNil());
            expect(testCell.secondaryArtwork).to(beNil());
        });

        it(@"should set initWithTitle:icon:voiceCommands:handler: properly", ^{
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
            testCell = [[SDLMenuCell alloc] initWithTitle:someTitle icon:someArtwork voiceCommands:someVoiceCommands handler:^(SDLTriggerSource  _Nonnull triggerSource) {}];
#pragma clang diagnostic pop

            expect(testCell.title).to(equal(someTitle));
            expect(testCell.icon).to(equal(someArtwork));
            expect(testCell.voiceCommands).to(equal(someVoiceCommands));
            expect(testCell.subCells).to(beNil());
            expect(testCell.uniqueTitle).to(equal(someTitle));
            expect(testCell.secondaryText).to(beNil());
            expect(testCell.tertiaryText).to(beNil());
            expect(testCell.secondaryArtwork).to(beNil());
        });

        it(@"should set initWithTitle:icon:voiceCommands:secondaryText:tertiaryText:secondaryArtwork:handler: properly", ^{
            testCell = [[SDLMenuCell alloc] initWithTitle:someTitle secondaryText:someSecondaryTitle tertiaryText:someTertiaryTitle icon:someArtwork secondaryArtwork:someSecondaryArtwork voiceCommands:someVoiceCommands handler:^(SDLTriggerSource  _Nonnull triggerSource) {}];

            expect(testCell.title).to(equal(someTitle));
            expect(testCell.icon).to(equal(someArtwork));
            expect(testCell.voiceCommands).to(equal(someVoiceCommands));
            expect(testCell.subCells).to(beNil());
            expect(testCell.secondaryText).to(equal(someSecondaryTitle));
            expect(testCell.tertiaryText).to(equal(someTertiaryTitle));
            expect(testCell.secondaryArtwork).to(equal(someSecondaryArtwork));
        });

        it(@"should initWithTitle:icon:submenuLayout:subCells:secondaryText:tertiaryText:secondaryArtwork: initialize", ^{
            testCell = [[SDLMenuCell alloc] initWithTitle:someTitle secondaryText:someSecondaryTitle tertiaryText:someTertiaryTitle icon:someArtwork secondaryArtwork:someSecondaryArtwork submenuLayout:testLayout subCells:someSubcells];

            expect(testCell.title).to(equal(someTitle));
            expect(testCell.icon).to(equal(someArtwork));
            expect(testCell.voiceCommands).to(beNil());
            expect(testCell.subCells).to(equal(someSubcells));
            expect(testCell.submenuLayout).to(equal(testLayout));
            expect(testCell.uniqueTitle).to(equal(someTitle));
            expect(testCell.secondaryText).to(equal(someSecondaryTitle));
            expect(testCell.tertiaryText).to(equal(someTertiaryTitle));
            expect(testCell.secondaryArtwork).to(equal(someSecondaryArtwork));
        });
    });

    describe(@"check cell eqality", ^{
        it(@"should compare cells and return true if cells equal", ^{
            testCell = [[SDLMenuCell alloc] initWithTitle:someTitle secondaryText:someSecondaryTitle tertiaryText:someTertiaryTitle icon:nil secondaryArtwork:someSecondaryArtwork submenuLayout:testLayout subCells:@[]];
            testCell2 = [[SDLMenuCell alloc] initWithTitle:someTitle secondaryText:someSecondaryTitle tertiaryText:someTertiaryTitle icon:nil secondaryArtwork:someSecondaryArtwork submenuLayout:testLayout subCells:@[]];

            expect([testCell isEqual:testCell2]).to(equal(true));
        });

        it(@"should compare cells and return false if not equal ", ^{
            testCell = [[SDLMenuCell alloc] initWithTitle:@"True" secondaryText:someSecondaryTitle tertiaryText:someTertiaryTitle icon:nil secondaryArtwork:someSecondaryArtwork submenuLayout:testLayout subCells:@[]];
            testCell2 = [[SDLMenuCell alloc] initWithTitle:@"False" secondaryText:nil tertiaryText:nil icon:nil secondaryArtwork:nil submenuLayout:testLayout subCells:@[]];

            expect([testCell isEqual:testCell2]).to(equal(false));
        });

        it(@"should compare cells and return true if cells equal", ^{
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
            testCell = [[SDLMenuCell alloc] initWithTitle:someTitle icon:nil submenuLayout:testLayout subCells:@[]];
            testCell2 = [[SDLMenuCell alloc] initWithTitle:someTitle icon:nil submenuLayout:testLayout subCells:@[]];
#pragma clang diagnostic pop

            expect([testCell isEqual:testCell2]).to(equal(true));
        });

        it(@"should compare cells and return false if not equal ", ^{
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
            testCell = [[SDLMenuCell alloc] initWithTitle:@"True" icon:nil submenuLayout:testLayout subCells:@[]];
            testCell2 = [[SDLMenuCell alloc] initWithTitle:@"False" icon:nil submenuLayout:testLayout subCells:@[]];
#pragma clang diagnostic pop

            expect([testCell isEqual:testCell2]).to(equal(false));
        });
    });
});

QuickSpecEnd