resourcerer 2.0.4 → 2.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,6 @@
1
1
  export const hasErrored = (loadingStates) => qualifyLoadingStates(loadingStates).some((state) => state === "error");
2
- export const isLoading = (loadingStates) => qualifyLoadingStates(loadingStates).some((state) => state === "loading");
2
+ export const isLoading = (loadingStates) => qualifyLoadingStates(loadingStates).some((state) => state === "loading") &&
3
+ !qualifyLoadingStates(loadingStates).some((state) => state === "error");
3
4
  export const hasLoaded = (loadingStates) => qualifyLoadingStates(loadingStates).every((state) => state === "loaded");
4
5
  export const isPending = (loadingStates) => qualifyLoadingStates(loadingStates).some((state) => state === "pending");
5
6
  export function noOp() { }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "resourcerer",
3
- "version": "2.0.4",
3
+ "version": "2.0.5",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "github.com/noahgrant/resourcerer"
@@ -39,9 +39,10 @@ describe("Utils", () => {
39
39
 
40
40
  describe("isLoading method", () => {
41
41
  it("returns true if any loading state is loading", () => {
42
- expect(isLoading(["error", "loading"])).toBe(true);
42
+ expect(isLoading(["pending", "loading", "loading"])).toBe(true);
43
+ expect(isLoading(["loaded", "loading"])).toBe(true);
43
44
  expect(isLoading("loading")).toBe(true);
44
- expect(Utils.isLoading(["error", "loading"])).toBe(true);
45
+ expect(Utils.isLoading(["loaded", "loading"])).toBe(true);
45
46
  expect(Utils.isLoading("loading")).toBe(true);
46
47
  });
47
48
 
@@ -52,6 +53,11 @@ describe("Utils", () => {
52
53
  expect(Utils.isLoading("loaded")).toBe(false);
53
54
  });
54
55
 
56
+ it("returns false if any other loading states have errored", () => {
57
+ expect(isLoading(["error", "loading", "loaded"])).toBe(false);
58
+ expect(Utils.isLoading(["error", "loading", "loaded"])).toBe(false);
59
+ });
60
+
55
61
  it("returns false if an undefined loading state is passed", () => {
56
62
  expect(isLoading(undefined)).toBe(false);
57
63
  expect(Utils.isLoading(undefined)).toBe(false);