-
Notifications
You must be signed in to change notification settings - Fork 25k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(core): allow passing value of any type to
isSignal
function (#5…
…0035) Unlike the current signature where the input argument must a function, this change allows an input of any type to be passed to the `isSignal` function. PR Close #50035
- Loading branch information
1 parent
fab7f39
commit 165b8b6
Showing
3 changed files
with
42 additions
and
4 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
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,36 @@ | ||
/** | ||
* @license | ||
* Copyright Google LLC All Rights Reserved. | ||
* | ||
* Use of this source code is governed by an MIT-style license that can be | ||
* found in the LICENSE file at https://angular.io/license | ||
*/ | ||
|
||
import {computed, isSignal, signal} from '@angular/core/src/signals'; | ||
|
||
describe('isSignal', () => { | ||
it('should return true for writable signal', () => { | ||
const writableSignal = signal('Angular'); | ||
expect(isSignal(writableSignal)).toBe(true); | ||
}); | ||
|
||
it('should return true for readonly signal', () => { | ||
const readonlySignal = computed(() => 10); | ||
expect(isSignal(readonlySignal)).toBe(true); | ||
}); | ||
|
||
it('should return false for primitive', () => { | ||
const primitive = 0; | ||
expect(isSignal(primitive)).toBe(false); | ||
}); | ||
|
||
it('should return false for object', () => { | ||
const object = {name: 'Angular'}; | ||
expect(isSignal(object)).toBe(false); | ||
}); | ||
|
||
it('should return false for function', () => { | ||
const fn = () => {}; | ||
expect(isSignal(fn)).toBe(false); | ||
}); | ||
}); |