Skip to content

Commit

Permalink
added unit test for react query browser side (#1791)
Browse files Browse the repository at this point in the history
  • Loading branch information
zenz34 authored Jan 25, 2021
1 parent a284f74 commit a1dbf57
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions packages/xarc-react-query/test/spec/browser-index.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
//
import { reactQueryFeature } from "../../src/browser/index";
import { describe, it } from "mocha";
import { expect } from "chai";
import React from "react";
import { SubAppDef, envHooks } from "@xarc/subapp";
import { SubAppContainer } from "@xarc/subapp";

describe("reactQueryFeature", function () {
it("should return a feature factory", async () => {
const factory = reactQueryFeature({ React });
expect(factory.id).equal("state-provider");
expect(factory.subId).equal("react-query");
expect(factory.add).to.be.a("function");
});

it("should add react-query feature to a subapp", async () => {
const container = new SubAppContainer({});
envHooks.getContainer = () => container;
const factory = reactQueryFeature({ React });
const def = {
name: "test",
getModule() {
return Promise.resolve({});
},
_features: {}
} as SubAppDef;
container.declare("test", def);

factory.add(def);

expect(def._features.reactQuery).to.be.an("object");
});
});

0 comments on commit a1dbf57

Please sign in to comment.