-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: isASignal function allows to check if an object is a signal
- Loading branch information
1 parent
74f2521
commit c6be621
Showing
3 changed files
with
47 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { $signal, isASignal } from "../core"; | ||
|
||
describe("isASignal", () => { | ||
test("checks that a value is a signal", () => { | ||
const signal = $signal(0); | ||
expect(isASignal(signal)).toBe(true); | ||
}); | ||
|
||
test("checks that a computed is a signal", () => { | ||
const signal = $signal(0); | ||
const computed = $signal(() => signal.value); | ||
expect(isASignal(computed)).toBe(true); | ||
}); | ||
|
||
test("checks that a value is not a signal", () => { | ||
expect(isASignal(0)).toBe(false); | ||
}); | ||
|
||
test("checks that a function is not a signal", () => { | ||
expect(isASignal(() => {})).toBe(false); | ||
}); | ||
|
||
test("checks that an object is not a signal", () => { | ||
expect(isASignal({})).toBe(false); | ||
}); | ||
|
||
test("checks that an array is not a signal", () => { | ||
expect(isASignal([])).toBe(false); | ||
}); | ||
|
||
test("checks that undefined is not a signal", () => { | ||
expect(isASignal(undefined)).toBe(false); | ||
}); | ||
|
||
test("checks that null is not a signal", () => { | ||
expect(isASignal(null)).toBe(false); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters