Commit 3194148c by Dima Bart

Add BUYClient+Routing tests.

parent b3601806
//
// 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(
[self.client routeForAPI].absoluteString,
@"https://_DOMAIN_/api"
);
XCTAssertEqualObjects(
[self.client routeForApps].absoluteString,
@"https://_DOMAIN_/api/apps/_APP_ID_"
);
XCTAssertEqualObjects(
[self.client routeForShop].absoluteString,
@"https://_DOMAIN_/meta.json"
);
XCTAssertEqualObjects(
[self.client routeForProductListingsWithParameters:parameters].absoluteString,
@"https://_DOMAIN_/api/apps/_APP_ID_/product_listings.json?param=value"
);
XCTAssertEqualObjects(
[self.client routeForCollectionListingsWithParameters:parameters].absoluteString,
@"https://_DOMAIN_/api/apps/_APP_ID_/collection_listings.json?param=value"
);
XCTAssertEqualObjects(
[self.client routeForCheckouts].absoluteString,
@"https://_DOMAIN_/api/checkouts.json"
);
XCTAssertEqualObjects(
[self.client routeForCheckoutsWithToken:token].absoluteString,
@"https://_DOMAIN_/api/checkouts/_TOKEN_.json"
);
XCTAssertEqualObjects(
[self.client routeForCheckoutsProcessingWithToken:token].absoluteString,
@"https://_DOMAIN_/api/checkouts/_TOKEN_/processing.json"
);
XCTAssertEqualObjects(
[self.client routeForCheckoutsCompletionWithToken:token].absoluteString,
@"https://_DOMAIN_/api/checkouts/_TOKEN_/complete.json"
);
XCTAssertEqualObjects(
[self.client routeForCheckoutsShippingRatesWithToken:token parameters:parameters].absoluteString,
@"https://_DOMAIN_/api/checkouts/_TOKEN_/shipping_rates.json?param=value"
);
XCTAssertEqualObjects(
[self.client routeForCheckoutsUsingGiftCard].absoluteString,
@"https://_DOMAIN_/api/checkouts/gift_cards.json"
);
XCTAssertEqualObjects(
[self.client routeForCheckoutsUsingGiftCardWithToken:token].absoluteString,
@"https://_DOMAIN_/api/checkouts/_TOKEN_/gift_cards.json"
);
XCTAssertEqualObjects(
[self.client routeForCheckoutsUsingGiftCard:@999 token:token].absoluteString,
@"https://_DOMAIN_/api/checkouts/_TOKEN_/gift_cards/999.json"
);
XCTAssertEqualObjects(
[self.client routeForCustomers].absoluteString,
@"https://_DOMAIN_/api/customers.json"
);
XCTAssertEqualObjects(
[self.client routeForCustomersOrders].absoluteString,
@"https://_DOMAIN_/api/customers/orders.json"
);
XCTAssertEqualObjects(
[self.client routeForCustomersWithID:identifier].absoluteString,
@"https://_DOMAIN_/api/customers/_ID_.json"
);
XCTAssertEqualObjects(
[self.client routeForCustomersActivationWithID:identifier parameters:parameters].absoluteString,
@"https://_DOMAIN_/api/customers/_ID_/activate.json?param=value"
);
XCTAssertEqualObjects(
[self.client routeForCustomersToken].absoluteString,
@"https://_DOMAIN_/api/customers/customer_token.json"
);
XCTAssertEqualObjects(
[self.client routeForCustomersTokenRenewalWithID:identifier].absoluteString,
@"https://_DOMAIN_/api/customers/_ID_/customer_token/renew.json"
);
XCTAssertEqualObjects(
[self.client routeForCustomersPasswordRecovery].absoluteString,
@"https://_DOMAIN_/api/customers/recover.json"
);
XCTAssertEqualObjects(
[self.client routeForCustomersPasswordResetWithID:identifier parameters:parameters].absoluteString,
@"https://_DOMAIN_/api/customers/_ID_/reset.json?param=value"
);
}
@end
......@@ -355,6 +355,7 @@
9A0B0C791CEB5BBD0037D68F /* BUYAuthenticatedResponse.h in Headers */ = {isa = PBXBuildFile; fileRef = 9A0B0C761CEB5BBD0037D68F /* BUYAuthenticatedResponse.h */; };
9A0B0C7A1CEB5BBD0037D68F /* BUYAuthenticatedResponse.m in Sources */ = {isa = PBXBuildFile; fileRef = 9A0B0C771CEB5BBD0037D68F /* BUYAuthenticatedResponse.m */; };
9A0B0C7B1CEB5BBD0037D68F /* BUYAuthenticatedResponse.m in Sources */ = {isa = PBXBuildFile; fileRef = 9A0B0C771CEB5BBD0037D68F /* BUYAuthenticatedResponse.m */; };
9A0B0C831CEB981C0037D68F /* BUYClient+RoutingTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 9A0B0C821CEB981C0037D68F /* BUYClient+RoutingTests.m */; };
9A102D1B1CDD1F960026CC43 /* BUYErrorTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 9A102D1A1CDD1F960026CC43 /* BUYErrorTests.m */; };
9A102D1E1CDD25980026CC43 /* BUYOptionValueTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 9A102D1D1CDD25980026CC43 /* BUYOptionValueTests.m */; };
9A47CEFD1CE39F6000A6D5BA /* BUYCreditCardToken.m in Sources */ = {isa = PBXBuildFile; fileRef = 9A47CEFB1CE39F5B00A6D5BA /* BUYCreditCardToken.m */; };
......@@ -637,6 +638,7 @@
9A0B0C711CEB52B90037D68F /* BUYClient+Checkout.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "BUYClient+Checkout.m"; sourceTree = "<group>"; };
9A0B0C761CEB5BBD0037D68F /* BUYAuthenticatedResponse.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BUYAuthenticatedResponse.h; sourceTree = "<group>"; };
9A0B0C771CEB5BBD0037D68F /* BUYAuthenticatedResponse.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BUYAuthenticatedResponse.m; sourceTree = "<group>"; };
9A0B0C821CEB981C0037D68F /* BUYClient+RoutingTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "BUYClient+RoutingTests.m"; sourceTree = "<group>"; };
9A102D1A1CDD1F960026CC43 /* BUYErrorTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BUYErrorTests.m; sourceTree = "<group>"; };
9A102D1D1CDD25980026CC43 /* BUYOptionValueTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BUYOptionValueTests.m; sourceTree = "<group>"; };
9A47CEF81CE39EC200A6D5BA /* BUYPaymentToken.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BUYPaymentToken.h; sourceTree = "<group>"; };
......@@ -935,6 +937,7 @@
90F592FB1B0D5F4C0026B382 /* BUYCheckoutTest.m */,
8498DCBF1CDD208200BD12A8 /* BUYClientTest_Customer.m */,
90F592FC1B0D5F4C0026B382 /* BUYClientTest_Storefront.m */,
9A0B0C821CEB981C0037D68F /* BUYClient+RoutingTests.m */,
90F592FD1B0D5F4C0026B382 /* BUYClientTest.m */,
BEB9AE7A1BA866D000575F8A /* BUYClientTestBase.h */,
BEB9AE7C1BA8685600575F8A /* BUYClientTestBase.m */,
......@@ -1647,6 +1650,7 @@
849110441CCE9F3F00E53B93 /* BUYTransformerTests.m in Sources */,
8498DCCC1CDD208200BD12A8 /* BUYCustomerTests.m in Sources */,
8498DCCE1CDD208200BD12A8 /* BUYOrderTests.m in Sources */,
9A0B0C831CEB981C0037D68F /* BUYClient+RoutingTests.m in Sources */,
849110351CCE70CE00E53B93 /* BUYDictionaryAdditionsTests.m in Sources */,
90F5930A1B0D5F4C0026B382 /* BUYLineItemTest.m in Sources */,
8498DCCA1CDD208200BD12A8 /* BUYCollectionTests.m in Sources */,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment