UNPKG

@apite/magento2-utility

Version:

Shopgate WebCheckout utility for Magento 2 extensions

35 lines (30 loc) 1.44 kB
'use strict' const path = require('path') const { GraphQLError } = require('../../src/lib/errorList') const loadFixtures = require('../fixtureLoader') const guestFixtures = loadFixtures(path.join(__dirname, '__fixtures__/guest')) const customerFixtures = loadFixtures(path.join(__dirname, '__fixtures__/customer')) describe('Should check the error formatter type responses to be consistent', () => { Object.keys(guestFixtures).forEach((fixtureName) => { it(`Type check for fixture "${fixtureName}"`, async () => { const GqlError = new GraphQLError(guestFixtures[fixtureName]) const result = GqlError.getFormattedError() expect(typeof result.call).toBe('string') expect(typeof result.headers.Store).toBe('string') expect(typeof result.data.query).toBe('string') }) }) }) describe('Should check the GraphQL formatter types for customers', () => { Object.keys(customerFixtures).forEach((fixtureName) => { it(`Type check customer fixture "${fixtureName}"`, async () => { const GqlError = new GraphQLError(customerFixtures[fixtureName]) const result = GqlError.getFormattedError() expect(typeof result.call).toBe('string') expect(typeof result.headers.Store).toBe('string') expect(typeof result.data.query).toBe('string') expect(typeof result.headers.Authorization).toBe('string') expect(result.headers.Authorization).toHaveLength(13) }) }) })