Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump graphql-js-client to 0.11.0 #638

Merged
merged 2 commits into from
Mar 7, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"expect.js": "0.3.1",
"fetch-mock": "5.12.2",
"fs-extra": "1.0.0",
"graphql-js-client": "0.9.2",
"graphql-js-client": "0.11.0",
"graphql-js-schema": "0.7.1",
"graphql-js-schema-fetch": "1.1.2",
"http-server": "0.10.0",
Expand Down
57 changes: 29 additions & 28 deletions test/client-checkout-integration-test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import assert from 'assert';
import Client from '../src/client';
import fetchMock from './isomorphic-fetch-mock'; // eslint-disable-line import/no-unresolved
import fetchMockPostOnce from './fetch-mock-helper';

// fixtures
import checkoutFixture from '../fixtures/checkout-fixture';
Expand Down Expand Up @@ -57,7 +58,7 @@ suite('client-checkout-integration-test', () => {
});

test('it resolves with a checkout on Client.checkout#fetch', () => {
fetchMock.postOnce(apiUrl, checkoutFixture);
fetchMockPostOnce(fetchMock, apiUrl, checkoutFixture);

const checkoutId = checkoutFixture.data.node.id;

Expand All @@ -68,7 +69,7 @@ suite('client-checkout-integration-test', () => {
});

test('it resolves with null on Client.checkout#fetch for a bad checkoutId', () => {
fetchMock.postOnce(apiUrl, checkoutNullFixture);
fetchMockPostOnce(fetchMock, apiUrl, checkoutNullFixture);

const checkoutId = checkoutFixture.data.node.id;

Expand All @@ -89,7 +90,7 @@ suite('client-checkout-integration-test', () => {
shippingAddress: {}
};

fetchMock.postOnce(apiUrl, checkoutCreateFixture);
fetchMockPostOnce(fetchMock, apiUrl, checkoutCreateFixture);

return client.checkout.create(input).then((checkout) => {
assert.equal(checkout.id, checkoutCreateFixture.data.checkoutCreate.checkout.id);
Expand All @@ -108,7 +109,7 @@ suite('client-checkout-integration-test', () => {
]
};

fetchMock.postOnce(apiUrl, checkoutUpdateAttributesV2Fixture);
fetchMockPostOnce(fetchMock, apiUrl, checkoutUpdateAttributesV2Fixture);

return client.checkout.updateAttributes(checkoutId, input).then((checkout) => {
assert.equal(checkout.id, checkoutUpdateAttributesV2Fixture.data.checkoutAttributesUpdateV2.checkout.id);
Expand All @@ -124,7 +125,7 @@ suite('client-checkout-integration-test', () => {
note: 'Very long note'
};

fetchMock.postOnce(apiUrl, checkoutUpdateAttributesV2WithUserErrorsFixture);
fetchMockPostOnce(fetchMock, apiUrl, checkoutUpdateAttributesV2WithUserErrorsFixture);

return client.checkout.updateAttributes(checkoutId, input).then(() => {
assert.ok(false, 'Promise should not resolve');
Expand All @@ -139,7 +140,7 @@ suite('client-checkout-integration-test', () => {
email: 'user@example.com'
};

fetchMock.postOnce(apiUrl, checkoutUpdateEmailV2Fixture);
fetchMockPostOnce(fetchMock, apiUrl, checkoutUpdateEmailV2Fixture);

return client.checkout.updateEmail(checkoutId, input).then((checkout) => {
assert.equal(checkout.id, checkoutUpdateEmailV2Fixture.data.checkoutEmailUpdateV2.checkout.id);
Expand All @@ -151,7 +152,7 @@ suite('client-checkout-integration-test', () => {
test('it resolve with user errors on Client.checkout#updateEmail when email is invalid', () => {
const checkoutId = checkoutUpdateEmailV2Fixture.data.checkoutEmailUpdateV2.checkout.id;

fetchMock.postOnce(apiUrl, checkoutUpdateEmailV2WithUserErrorsFixture);
fetchMockPostOnce(fetchMock, apiUrl, checkoutUpdateEmailV2WithUserErrorsFixture);

return client.checkout.updateEmail(checkoutId, {email: 'invalid-email'}).then(() => {
assert.ok(false, 'Promise should not resolve');
Expand All @@ -167,7 +168,7 @@ suite('client-checkout-integration-test', () => {
{variantId: 'id2', quantity: 2}
];

fetchMock.postOnce(apiUrl, checkoutLineItemsAddFixture);
fetchMockPostOnce(fetchMock, apiUrl, checkoutLineItemsAddFixture);

return client.checkout.addLineItems(checkoutId, lineItems).then((checkout) => {
assert.equal(checkout.id, checkoutId);
Expand All @@ -181,7 +182,7 @@ suite('client-checkout-integration-test', () => {
{variantId: '', quantity: 1}
];

fetchMock.postOnce(apiUrl, checkoutLineItemsAddWithUserErrorsFixture);
fetchMockPostOnce(fetchMock, apiUrl, checkoutLineItemsAddWithUserErrorsFixture);

return client.checkout.addLineItems(checkoutId, lineItems).then(() => {
assert.ok(false, 'Promise should not resolve');
Expand All @@ -197,7 +198,7 @@ suite('client-checkout-integration-test', () => {
{variantId: 'id2', quantity: 2}
];

fetchMock.postOnce(apiUrl, checkoutLineItemsReplaceFixture);
fetchMockPostOnce(fetchMock, apiUrl, checkoutLineItemsReplaceFixture);

return client.checkout.replaceLineItems(checkoutId, lineItems).then((checkout) => {
assert.equal(checkout.id, checkoutId);
Expand All @@ -211,7 +212,7 @@ suite('client-checkout-integration-test', () => {
{variantId: '', quantity: 1}
];

fetchMock.postOnce(apiUrl, checkoutLineItemsReplaceWithUserErrorsFixture);
fetchMockPostOnce(fetchMock, apiUrl, checkoutLineItemsReplaceWithUserErrorsFixture);

return client.checkout.replaceLineItems(checkoutId, lineItems).then(() => {
assert.ok(false, 'Promise should not resolve');
Expand All @@ -230,7 +231,7 @@ suite('client-checkout-integration-test', () => {
}
];

fetchMock.postOnce(apiUrl, checkoutLineItemsUpdateFixture);
fetchMockPostOnce(fetchMock, apiUrl, checkoutLineItemsUpdateFixture);

return client.checkout.updateLineItems(checkoutId, lineItems).then((checkout) => {
assert.equal(checkout.id, checkoutId);
Expand All @@ -248,7 +249,7 @@ suite('client-checkout-integration-test', () => {
}
];

fetchMock.postOnce(apiUrl, checkoutLineItemsUpdateWithUserErrorsFixture);
fetchMockPostOnce(fetchMock, apiUrl, checkoutLineItemsUpdateWithUserErrorsFixture);

return client.checkout.updateLineItems(checkoutId, lineItems).then(() => {
assert.ok(false, 'Promise should not resolve');
Expand All @@ -260,7 +261,7 @@ suite('client-checkout-integration-test', () => {
test('it resolves with a checkout on Client.checkout#removeLineItems', () => {
const checkoutId = checkoutLineItemsRemoveFixture.data.checkoutLineItemsRemove.checkout.id;

fetchMock.postOnce(apiUrl, checkoutLineItemsRemoveFixture);
fetchMockPostOnce(fetchMock, apiUrl, checkoutLineItemsRemoveFixture);

return client.checkout.removeLineItems(checkoutId, ['line-item-id']).then((checkout) => {
assert.equal(checkout.id, checkoutId);
Expand All @@ -271,7 +272,7 @@ suite('client-checkout-integration-test', () => {
test('it resolves with user errors on Client.checkout#removeLineItems when line item is invalid', () => {
const checkoutId = checkoutLineItemsRemoveFixture.data.checkoutLineItemsRemove.checkout.id;

fetchMock.postOnce(apiUrl, checkoutLineItemsRemoveWithUserErrorsFixture);
fetchMockPostOnce(fetchMock, apiUrl, checkoutLineItemsRemoveWithUserErrorsFixture);

return client.checkout.removeLineItems(checkoutId, ['invalid-line-item-id']).then(() => {
assert.ok(false, 'Promise should not resolve');
Expand All @@ -284,7 +285,7 @@ suite('client-checkout-integration-test', () => {
const checkoutId = checkoutDiscountCodeApplyV2Fixture.data.checkoutDiscountCodeApplyV2.checkout.id;
const discountCode = 'TENPERCENTOFF';

fetchMock.postOnce(apiUrl, checkoutDiscountCodeApplyV2Fixture);
fetchMockPostOnce(fetchMock, apiUrl, checkoutDiscountCodeApplyV2Fixture);

return client.checkout.addDiscount(checkoutId, discountCode).then((checkout) => {
assert.equal(checkout.id, checkoutId);
Expand Down Expand Up @@ -314,7 +315,7 @@ suite('client-checkout-integration-test', () => {
}
};

fetchMock.postOnce(apiUrl, checkoutDiscountCodeApplyV2WithCheckoutUserErrorsFixture);
fetchMockPostOnce(fetchMock, apiUrl, checkoutDiscountCodeApplyV2WithCheckoutUserErrorsFixture);

const checkoutId = checkoutDiscountCodeApplyV2Fixture.data.checkoutDiscountCodeApplyV2.checkout.id;
const discountCode = 'INVALIDCODE';
Expand All @@ -329,7 +330,7 @@ suite('client-checkout-integration-test', () => {
test('it resolves with a checkout on Client.checkout#removeDiscount', () => {
const checkoutId = checkoutDiscountCodeRemoveFixture.data.checkoutDiscountCodeRemove.checkout.id;

fetchMock.postOnce(apiUrl, checkoutDiscountCodeRemoveFixture);
fetchMockPostOnce(fetchMock, apiUrl, checkoutDiscountCodeRemoveFixture);

return client.checkout.removeDiscount(checkoutId).then((checkout) => {
assert.equal(checkout.id, checkoutId);
Expand All @@ -345,7 +346,7 @@ suite('client-checkout-integration-test', () => {
countryCode: shippingCountry
} = checkoutShippingAddressUpdateV2Fixture.data.checkoutShippingAddressUpdateV2.checkout.shippingAddress;

fetchMock.postOnce(apiUrl, checkoutShippingAddressUpdateV2Fixture);
fetchMockPostOnce(fetchMock, apiUrl, checkoutShippingAddressUpdateV2Fixture);

return client.checkout.updateShippingAddress(checkoutId, shippingAddress).then((checkout) => {
assert.equal(checkout.id, checkoutId);
Expand All @@ -359,7 +360,7 @@ suite('client-checkout-integration-test', () => {
test('it resolves with user errors on Client.checkout#updateShippingAddress with invalid address', () => {
const checkoutId = checkoutShippingAddressUpdateV2Fixture.data.checkoutShippingAddressUpdateV2.checkout.id;

fetchMock.postOnce(apiUrl, checkoutShippingAdddressUpdateV2WithUserErrorsFixture);
fetchMockPostOnce(fetchMock, apiUrl, checkoutShippingAdddressUpdateV2WithUserErrorsFixture);

return client.checkout.updateShippingAddress(checkoutId, shippingAddress).then(() => {
assert.ok(false, 'Promise should not resolve.');
Expand All @@ -377,9 +378,9 @@ suite('client-checkout-integration-test', () => {
]
};

fetchMock.postOnce(apiUrl, checkoutCreateWithPaginatedLineItemsFixture)
.postOnce(apiUrl, secondPageLineItemsFixture)
.postOnce(apiUrl, thirdPageLineItemsFixture);
fetchMockPostOnce(fetchMock, apiUrl, checkoutCreateWithPaginatedLineItemsFixture);
fetchMockPostOnce(fetchMock, apiUrl, secondPageLineItemsFixture);
fetchMockPostOnce(fetchMock, apiUrl, thirdPageLineItemsFixture);

return client.checkout.create(input).then(() => {
assert.ok(fetchMock.done());
Expand Down Expand Up @@ -411,7 +412,7 @@ suite('client-checkout-integration-test', () => {
]
};

fetchMock.postOnce(apiUrl, checkoutCreateWithUserErrorsFixture);
fetchMockPostOnce(fetchMock, apiUrl, checkoutCreateWithUserErrorsFixture);

return client.checkout.create(input).then(() => {
assert.ok(false, 'Promise should not resolve');
Expand All @@ -432,7 +433,7 @@ suite('client-checkout-integration-test', () => {
]
};

fetchMock.postOnce(apiUrl, checkoutCreateWithUserErrorsFixture);
fetchMockPostOnce(fetchMock, apiUrl, checkoutCreateWithUserErrorsFixture);

return client.checkout.create(input).then(() => {
assert.ok(false, 'Promise should not resolve');
Expand All @@ -452,9 +453,9 @@ suite('client-checkout-integration-test', () => {
]
};

fetchMock.postOnce(apiUrl, checkoutCreateWithPaginatedLineItemsFixture)
.postOnce(apiUrl, secondPageLineItemsFixture)
.postOnce(apiUrl, thirdPageLineItemsFixture);
fetchMockPostOnce(fetchMock, apiUrl, checkoutCreateWithPaginatedLineItemsFixture);
fetchMockPostOnce(fetchMock, apiUrl, secondPageLineItemsFixture);
fetchMockPostOnce(fetchMock, apiUrl, thirdPageLineItemsFixture);

return client.checkout.create(input).then((checkout) => {
assert.ok(checkout.errors);
Expand Down
Loading