BUYClient+RoutingTests.m 5.97 KB
Newer Older
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
//
//  BUYClient+RoutingTests.m
//  Mobile Buy SDK
//
//  Created by Shopify.
//  Copyright (c) 2015 Shopify Inc. All rights reserved.
//
//  Permission is hereby granted, free of charge, to any person obtaining a copy
//  of this software and associated documentation files (the "Software"), to deal
//  in the Software without restriction, including without limitation the rights
//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
//  copies of the Software, and to permit persons to whom the Software is
//  furnished to do so, subject to the following conditions:
//
//  The above copyright notice and this permission notice shall be included in
//  all copies or substantial portions of the Software.
//
//  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
//  THE SOFTWARE.
//

#import <XCTest/XCTest.h>
#import "BUYClient+Routing.h"

@interface BUYClient_RoutingTests : XCTestCase

@property (strong, nonatomic) BUYClient *client;

@end

@implementation BUYClient_RoutingTests

#pragma mark - Setup -

- (void)setUp
{
    [super setUp];
	
	self.client = [[BUYClient alloc] initWithShopDomain:@"_DOMAIN_" apiKey:@"_API_KEY_" appId:@"_APP_ID_"];
}

#pragma mark - Test Routes -

- (void)testRoutes
{
	NSString *identifier     = @"_ID_";
	NSString *token          = @"_TOKEN_";
	NSDictionary *parameters = @{ @"param" : @"value" };
	
	XCTAssertEqualObjects(
Dima Bart committed
56
						  [self.client urlForAPI].absoluteString,
57 58 59 60
						  @"https://_DOMAIN_/api"
						  );
	
	XCTAssertEqualObjects(
Dima Bart committed
61
						  [self.client urlForApps].absoluteString,
62 63 64 65
						  @"https://_DOMAIN_/api/apps/_APP_ID_"
						  );
	
	XCTAssertEqualObjects(
Dima Bart committed
66
						  [self.client urlForShop].absoluteString,
67 68 69
						  @"https://_DOMAIN_/meta.json"
						  );
	XCTAssertEqualObjects(
Dima Bart committed
70
						  [self.client urlForProductListingsWithParameters:parameters].absoluteString,
71 72 73
						  @"https://_DOMAIN_/api/apps/_APP_ID_/product_listings.json?param=value"
						  );
	XCTAssertEqualObjects(
Dima Bart committed
74
						  [self.client urlForCollectionListingsWithParameters:parameters].absoluteString,
75 76 77 78
						  @"https://_DOMAIN_/api/apps/_APP_ID_/collection_listings.json?param=value"
						  );
	
	XCTAssertEqualObjects(
Dima Bart committed
79
						  [self.client urlForCheckouts].absoluteString,
80 81 82
						  @"https://_DOMAIN_/api/checkouts.json"
						  );
	XCTAssertEqualObjects(
Dima Bart committed
83
						  [self.client urlForCheckoutsWithToken:token].absoluteString,
84 85 86
						  @"https://_DOMAIN_/api/checkouts/_TOKEN_.json"
						  );
	XCTAssertEqualObjects(
Dima Bart committed
87
						  [self.client urlForCheckoutsProcessingWithToken:token].absoluteString,
88 89 90
						  @"https://_DOMAIN_/api/checkouts/_TOKEN_/processing.json"
						  );
	XCTAssertEqualObjects(
Dima Bart committed
91
						  [self.client urlForCheckoutsCompletionWithToken:token].absoluteString,
92 93 94
						  @"https://_DOMAIN_/api/checkouts/_TOKEN_/complete.json"
						  );
	XCTAssertEqualObjects(
Dima Bart committed
95
						  [self.client urlForCheckoutsShippingRatesWithToken:token parameters:parameters].absoluteString,
96 97 98 99
						  @"https://_DOMAIN_/api/checkouts/_TOKEN_/shipping_rates.json?param=value"
						  );
	
	XCTAssertEqualObjects(
Dima Bart committed
100
						  [self.client urlForCheckoutsUsingGiftCard].absoluteString,
101 102 103
						  @"https://_DOMAIN_/api/checkouts/gift_cards.json"
						  );
	XCTAssertEqualObjects(
Dima Bart committed
104
						  [self.client urlForCheckoutsUsingGiftCardWithToken:token].absoluteString,
105 106 107
						  @"https://_DOMAIN_/api/checkouts/_TOKEN_/gift_cards.json"
						  );
	XCTAssertEqualObjects(
Dima Bart committed
108
						  [self.client urlForCheckoutsUsingGiftCard:@999 token:token].absoluteString,
109 110 111 112
						  @"https://_DOMAIN_/api/checkouts/_TOKEN_/gift_cards/999.json"
						  );
	
	XCTAssertEqualObjects(
Dima Bart committed
113
						  [self.client urlForCustomers].absoluteString,
114 115
						  @"https://_DOMAIN_/api/customers.json"
						  );
116 117 118 119 120 121 122 123
	XCTAssertEqualObjects(
						  [self.client urlForCustomersToken].absoluteString,
						  @"https://_DOMAIN_/api/customers/customer_token.json"
						  );
	XCTAssertEqualObjects(
						  [self.client urlForCustomersPasswordRecovery].absoluteString,
						  @"https://_DOMAIN_/api/customers/recover.json"
						  );
124 125 126 127 128 129 130 131
	XCTAssertEqualObjects(
						  [self.client urlForCustomersOrdersWithID:identifier].absoluteString,
						  @"https://_DOMAIN_/api/customers/_ID_/orders.json"
						  );
	XCTAssertEqualObjects(
						  [self.client urlForCustomersOrdersWithID:identifier orderID:@99].absoluteString,
						  @"https://_DOMAIN_/api/customers/_ID_/orders/99.json"
						  );
132
	XCTAssertEqualObjects(
Dima Bart committed
133
						  [self.client urlForCustomersWithID:identifier].absoluteString,
134 135 136
						  @"https://_DOMAIN_/api/customers/_ID_.json"
						  );
	XCTAssertEqualObjects(
Dima Bart committed
137
						  [self.client urlForCustomersActivationWithID:identifier parameters:parameters].absoluteString,
138 139
						  @"https://_DOMAIN_/api/customers/_ID_/activate.json?param=value"
						  );
140 141 142 143
	XCTAssertEqualObjects(
						  [self.client urlForCustomersTokenWithID:identifier].absoluteString,
						  @"https://_DOMAIN_/api/customers/_ID_/customer_token.json"
						  );
144
	XCTAssertEqualObjects(
Dima Bart committed
145
						  [self.client urlForCustomersTokenRenewalWithID:identifier].absoluteString,
146 147 148
						  @"https://_DOMAIN_/api/customers/_ID_/customer_token/renew.json"
						  );
	XCTAssertEqualObjects(
Dima Bart committed
149
						  [self.client urlForCustomersPasswordResetWithID:identifier parameters:parameters].absoluteString,
150 151
						  @"https://_DOMAIN_/api/customers/_ID_/reset.json?param=value"
						  );
152 153 154 155 156 157 158 159 160
	
	XCTAssertEqualObjects(
						  [self.client urlForCustomersAddressesWithID:identifier].absoluteString,
						  @"https://_DOMAIN_/api/customers/_ID_/addresses.json"
						  );
	XCTAssertEqualObjects(
						  [self.client urlForCustomersAddressWithID:identifier addressID:@999].absoluteString,
						  @"https://_DOMAIN_/api/customers/_ID_/addresses/999.json"
						  );
161 162 163
}

@end