reshow-return
Version:
reshow-return (simple connect component with reshow-flux)
52 lines (51 loc) • 1.45 kB
JavaScript
// @ts-check
import * as React from "react";
import { expect } from "chai";
import { render } from "reshow-unit";
import { Map, fromJS } from "reshow-flux";
import { createReducer } from "reshow-flux-base";
import useReturn from "../useReturn.mjs";
import { jsx as _jsx } from "react/jsx-runtime";
describe("Test useReturn", function () {
it("basic test", function () {
var [store] = createReducer(function (_state, action) {
return action;
}, {
foo: "bar"
});
var Dom = function Dom() {
var state = useReturn(["foo"], store);
return state.foo;
};
var wrap = render(/*#__PURE__*/_jsx(Dom, {}));
expect(wrap.html()).to.equal("bar");
});
it("test default immutable", function () {
var [store] = createReducer(function (_state, action) {
return action;
}, fromJS({
m: {}
}));
var Dom = function Dom() {
var state = useReturn(["m"], store);
expect(Map.isMap(state.m)).to.be.true;
return null;
};
render(/*#__PURE__*/_jsx(Dom, {}));
});
it("test default is not immutable", function () {
var [store] = createReducer(function (_state, action) {
return action;
}, fromJS({
m: {}
}));
var Dom = function Dom() {
var state = useReturn(["m"], store, {
immutable: false
});
expect(Map.isMap(state.m)).to.be.false;
return null;
};
render(/*#__PURE__*/_jsx(Dom, {}));
});
});