Skip to content
This repository has been archived by the owner on May 3, 2024. It is now read-only.

Commit

Permalink
feat(createTimeoutFetch): replaced @americanexpress/fetch-enhancers
Browse files Browse the repository at this point in the history
  • Loading branch information
JAdshead authored Jun 23, 2020
1 parent e8a1dd2 commit c12db6f
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 184 deletions.
17 changes: 10 additions & 7 deletions __tests__/client/prerender.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,16 @@ jest.mock('@americanexpress/one-app-ducks', () => ({
addErrorToReport: jest.fn(),
}));

jest.mock('../../src/universal/utils/createTimeoutFetch', () => jest.fn(
(timeout) => (next) => () => next()
.then((res) => {
res.timeout = timeout;
return res;
})
));
jest.mock('@americanexpress/fetch-enhancers', () => ({
createTimeoutFetch: jest.fn(
(timeout) => (next) => () => next()
.then((res) => {
res.timeout = timeout;
return res;
})
),
}));

jest.mock('../../src/client/service-worker', () => ({ initializeServiceWorker: jest.fn(() => Promise.resolve()) }));

describe('initializeClientStore', () => {
Expand Down
112 changes: 0 additions & 112 deletions __tests__/universal/utils/createTimeoutFetch.spec.js

This file was deleted.

6 changes: 0 additions & 6 deletions __tests__/universal/utils/transit.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import url from 'url';
import {
Map, OrderedMap, List, Set, OrderedSet, Record,
} from 'immutable';
import { TimeoutError } from '../../../src/universal/utils/createTimeoutFetch';

describe('transit', () => {
let { default: transit } = require('../../../src/universal/utils/transit');
Expand Down Expand Up @@ -77,11 +76,6 @@ describe('transit', () => {
expect(transform(input)).toEqual(input);
});

it('should serialize a TimeoutError into an object', () => {
const input = new TimeoutError();
expect(transform(input)).toEqual(input);
});

it('should convert Functions to null', () => {
const input = () => 0;
expect(transform(input)).toBe(null);
Expand Down
33 changes: 28 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
],
"dependencies": {
"@americanexpress/env-config-utils": "^2.0.2",
"@americanexpress/fetch-enhancers": "^1.0.0",
"@americanexpress/lumberjack": "^1.1.4",
"@americanexpress/one-app-bundler": "^6.6.0",
"@americanexpress/one-app-ducks": "^4.0.1",
Expand Down
2 changes: 1 addition & 1 deletion src/client/prerender.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
import { createHolocronStore } from 'holocron';
import { getLocalePack, addErrorToReport } from '@americanexpress/one-app-ducks';
import { compose } from 'redux';
import { createTimeoutFetch } from '@americanexpress/fetch-enhancers';

import createEnhancer from '../universal/enhancers';
import reducer from '../universal/reducers';
import transit from '../universal/utils/transit';
import createTimeoutFetch from '../universal/utils/createTimeoutFetch';
import { initializeServiceWorker } from './service-worker';

export function initializeClientStore() {
Expand Down
46 changes: 0 additions & 46 deletions src/universal/utils/createTimeoutFetch.js

This file was deleted.

7 changes: 0 additions & 7 deletions src/universal/utils/transit.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

import transit from 'transit-immutable-js';
import { serializeError } from 'serialize-error';
import { TimeoutError } from './createTimeoutFetch';

const concealOrigin = (href) => href && href.replace(/\/\/[^/]+/g, '//***');

Expand All @@ -43,12 +42,6 @@ export default transit.withExtraHandlers([
write: writeError,
read: (value) => Object.assign(new Error(), { stack: undefined }, value),
},
{
tag: 'timeoutError',
class: TimeoutError,
write: writeError,
read: (value) => Object.assign(new Error(), { stack: undefined }, value),
},
{
tag: 'promise',
class: Promise,
Expand Down

0 comments on commit c12db6f

Please sign in to comment.