Thanks to visit codestin.com
Credit goes to github.com

Skip to content
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
5 changes: 4 additions & 1 deletion tests/integration/api/queries/shop/shop.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ beforeAll(async () => {
}`);
});

afterAll(() => testApp.stop());
afterAll(async () => {
await testApp.collections.Shops.deleteMany({});
await testApp.stop();
});

test("get shop, no auth necessary", async () => {
const opaqueShopId = encodeShopOpaqueId(shopId);
Expand Down
48 changes: 48 additions & 0 deletions tests/integration/api/queries/shop/shopBySlug.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import { encodeShopOpaqueId } from "@reactioncommerce/reaction-graphql-xforms/shop";
import TestApp from "/imports/test-utils/helpers/TestApp";

jest.setTimeout(300000);

let shopBySlugQuery;
let shopId;
const shopName = "Slug Integration Test";
let testApp;
let opaqueShopId;
const shopSlug = "integ-test-shop-slug";

beforeAll(async () => {
testApp = new TestApp();
await testApp.start();
shopId = await testApp.insertPrimaryShop({ slug: shopSlug, name: shopName });
opaqueShopId = encodeShopOpaqueId(shopId);
shopBySlugQuery = testApp.query(`query ($slug: String!) {
shopBySlug(slug: $slug) {
_id
name
}
}`);
});

afterAll(async () => {
await testApp.collections.Shops.deleteMany({});
await testApp.stop();
});

test("get shop by slug success", async () => {
const result = await shopBySlugQuery({ slug: shopSlug });
expect(result.shopBySlug.name).toBe(shopName);
expect(result.shopBySlug._id).toBe(opaqueShopId);
});

test("get shop by slug failure", async () => {
const result = await shopBySlugQuery({ slug: "does-not-exist" });
expect(result.shopBySlug).toBeNull();
});

test("get invalid params error", async () => {
try {
await shopBySlugQuery({});
} catch (error) {
expect(error[0].message).toBe("Variable \"$slug\" of required type \"String!\" was not provided.");
}
});