apply prettier, removed flow related config and added tsconfig

This commit is contained in:
Sebastian Sdorra
2019-10-20 18:02:52 +02:00
parent 0e017dcadd
commit 490418d06e
231 changed files with 5771 additions and 30386 deletions

View File

@@ -1,168 +1,168 @@
import reducer, { isPending } from './pending';
import reducer, { isPending } from "./pending";
describe('pending reducer', () => {
it('should set pending for FETCH_ITEMS to true', () => {
describe("pending reducer", () => {
it("should set pending for FETCH_ITEMS to true", () => {
const newState = reducer(
{},
{
type: 'FETCH_ITEMS_PENDING',
},
type: "FETCH_ITEMS_PENDING"
}
);
expect(newState['FETCH_ITEMS']).toBe(true);
expect(newState["FETCH_ITEMS"]).toBe(true);
});
it('should do nothing for unknown action types', () => {
it("should do nothing for unknown action types", () => {
const state = {};
const newState = reducer(state, {
type: 'UNKNOWN',
type: "UNKNOWN"
});
expect(newState).toBe(state);
});
it('should set pending for FETCH_ITEMS to true, but should not affect others', () => {
it("should set pending for FETCH_ITEMS to true, but should not affect others", () => {
const newState = reducer(
{
FETCH_USERS: true
},
{
type: "FETCH_ITEMS_PENDING"
}
);
expect(newState["FETCH_ITEMS"]).toBe(true);
expect(newState["FETCH_USERS"]).toBe(true);
});
it("should reset pending state for FETCH_ITEMS after FETCH_ITEMS_SUCCESS", () => {
const newState = reducer(
{
FETCH_ITEMS: true
},
{
type: "FETCH_ITEMS_SUCCESS"
}
);
expect(newState["FETCH_ITEMS"]).toBeFalsy();
});
it("should reset pending state for FETCH_ITEMS after FETCH_ITEMS_FAILURE", () => {
const newState = reducer(
{
FETCH_ITEMS: true
},
{
type: "FETCH_ITEMS_FAILURE"
}
);
expect(newState["FETCH_ITEMS"]).toBeFalsy();
});
it("should reset pending state for FETCH_ITEMS after FETCH_ITEMS_RESET", () => {
const newState = reducer(
{
FETCH_ITEMS: true
},
{
type: "FETCH_ITEMS_RESET"
}
);
expect(newState["FETCH_ITEMS"]).toBeFalsy();
});
it("should reset pending state for FETCH_ITEMS, if resetPending prop is available", () => {
const newState = reducer(
{
FETCH_ITEMS: true
},
{
type: "FETCH_ITEMS_SOMETHING",
resetPending: true
}
);
expect(newState["FETCH_ITEMS"]).toBeFalsy();
});
it("should reset pending state for FETCH_ITEMS after FETCH_ITEMS_SUCCESS, but should not affect others", () => {
const newState = reducer(
{
FETCH_USERS: true,
FETCH_ITEMS: true
},
{
type: 'FETCH_ITEMS_PENDING',
},
type: "FETCH_ITEMS_SUCCESS"
}
);
expect(newState['FETCH_ITEMS']).toBe(true);
expect(newState['FETCH_USERS']).toBe(true);
expect(newState["FETCH_ITEMS"]).toBeFalsy();
expect(newState["FETCH_USERS"]).toBe(true);
});
it('should reset pending state for FETCH_ITEMS after FETCH_ITEMS_SUCCESS', () => {
it("should set pending for a single item", () => {
const newState = reducer(
{
FETCH_ITEMS: true,
"FETCH_USER/42": false
},
{
type: 'FETCH_ITEMS_SUCCESS',
},
type: "FETCH_USER_PENDING",
itemId: 21
}
);
expect(newState['FETCH_ITEMS']).toBeFalsy();
expect(newState["FETCH_USER/21"]).toBe(true);
expect(newState["FETCH_USER/42"]).toBe(false);
});
it('should reset pending state for FETCH_ITEMS after FETCH_ITEMS_FAILURE', () => {
it("should reset pending for a single item", () => {
const newState = reducer(
{
FETCH_ITEMS: true,
"FETCH_USER/42": true
},
{
type: 'FETCH_ITEMS_FAILURE',
},
type: "FETCH_USER_SUCCESS",
itemId: 42
}
);
expect(newState['FETCH_ITEMS']).toBeFalsy();
});
it('should reset pending state for FETCH_ITEMS after FETCH_ITEMS_RESET', () => {
const newState = reducer(
{
FETCH_ITEMS: true,
},
{
type: 'FETCH_ITEMS_RESET',
},
);
expect(newState['FETCH_ITEMS']).toBeFalsy();
});
it('should reset pending state for FETCH_ITEMS, if resetPending prop is available', () => {
const newState = reducer(
{
FETCH_ITEMS: true,
},
{
type: 'FETCH_ITEMS_SOMETHING',
resetPending: true,
},
);
expect(newState['FETCH_ITEMS']).toBeFalsy();
});
it('should reset pending state for FETCH_ITEMS after FETCH_ITEMS_SUCCESS, but should not affect others', () => {
const newState = reducer(
{
FETCH_USERS: true,
FETCH_ITEMS: true,
},
{
type: 'FETCH_ITEMS_SUCCESS',
},
);
expect(newState['FETCH_ITEMS']).toBeFalsy();
expect(newState['FETCH_USERS']).toBe(true);
});
it('should set pending for a single item', () => {
const newState = reducer(
{
'FETCH_USER/42': false,
},
{
type: 'FETCH_USER_PENDING',
itemId: 21,
},
);
expect(newState['FETCH_USER/21']).toBe(true);
expect(newState['FETCH_USER/42']).toBe(false);
});
it('should reset pending for a single item', () => {
const newState = reducer(
{
'FETCH_USER/42': true,
},
{
type: 'FETCH_USER_SUCCESS',
itemId: 42,
},
);
expect(newState['FETCH_USER/42']).toBeFalsy();
expect(newState["FETCH_USER/42"]).toBeFalsy();
});
});
describe('pending selectors', () => {
it('should return true, while FETCH_ITEMS is pending', () => {
describe("pending selectors", () => {
it("should return true, while FETCH_ITEMS is pending", () => {
const result = isPending(
{
pending: {
FETCH_ITEMS: true,
},
FETCH_ITEMS: true
}
},
'FETCH_ITEMS',
"FETCH_ITEMS"
);
expect(result).toBe(true);
});
it('should return false, if pending is not defined', () => {
const result = isPending({}, 'FETCH_ITEMS');
it("should return false, if pending is not defined", () => {
const result = isPending({}, "FETCH_ITEMS");
expect(result).toBe(false);
});
it('should return true, while FETCH_ITEM 42 is pending', () => {
it("should return true, while FETCH_ITEM 42 is pending", () => {
const result = isPending(
{
pending: {
'FETCH_ITEM/42': true,
},
"FETCH_ITEM/42": true
}
},
'FETCH_ITEM',
42,
"FETCH_ITEM",
42
);
expect(result).toBe(true);
});
it('should return true, while FETCH_ITEM 42 is undefined', () => {
it("should return true, while FETCH_ITEM 42 is undefined", () => {
const result = isPending(
{
pending: {
'FETCH_ITEM/21': true,
},
"FETCH_ITEM/21": true
}
},
'FETCH_ITEM',
42,
"FETCH_ITEM",
42
);
expect(result).toBe(false);
});