Skip to content

Commit

Permalink
Merge e70df6a into 5be02ae
Browse files Browse the repository at this point in the history
  • Loading branch information
maxdobler committed Jul 4, 2019
2 parents 5be02ae + e70df6a commit 0767719
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
12 changes: 10 additions & 2 deletions src/batteries.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,22 @@ import { causing } from "./cause";
import { effector } from "./effect";
import { trigger } from "./event";
import { db } from "./db";
import { connector } from "./connector"

/**
* Cause that returs the state of the database signal.
* Cause that returns the state of the database signal.
*
* @see {@link db}
*/
causing("db", () => db.value());

/**
* Connector that connects to the database state.
*
* @see {@link db}
*/
connector("db", () => db.value());

/**
* Cause that returns the current time.
*/
Expand Down Expand Up @@ -78,7 +86,7 @@ effector(
for (let name in headers) {
xhr.setRequestHeader(name, headers[name]);
}
xhr.onload = xhr.onerror = function() {
xhr.onload = xhr.onerror = function () {
switch (this.status) {
case STATUS_OK:
case STATUS_CREATED:
Expand Down
9 changes: 8 additions & 1 deletion src/batteries.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ beforeEach(() => {
trigger.mockClear();
});

window.XMLHttpRequest = function() {
window.XMLHttpRequest = function () {
let xhr = {
open: jest.fn(),
send: jest.fn(),
Expand All @@ -30,6 +30,13 @@ describe("db cause", () => {
});
});

describe("db connector", () => {
it("should return the state of db", () => {
db.reset({ foo: "bar" });
expect(connect("db")).toStrictEqual({ foo: "bar" });
});
});

describe("now cause", () => {
it("should return the current time", () => {
let now = Date.now();
Expand Down

0 comments on commit 0767719

Please sign in to comment.