File tree 2 files changed +9
-4
lines changed
test/integration/builtin/filters
2 files changed +9
-4
lines changed Original file line number Diff line number Diff line change 1
- import { isTruthy } from '../../render/syntax'
1
+ import { isFalsy } from '../../render/syntax'
2
2
3
3
export default {
4
- 'default' : < T1 , T2 > ( v : T1 , arg : T2 ) : T1 | T2 => isTruthy ( v ) ? v : arg
4
+ 'default' : < T1 , T2 > ( v : string | T1 , arg : T2 ) : string | T1 | T2 => isFalsy ( v ) || v === '' ? arg : v
5
5
}
Original file line number Diff line number Diff line change @@ -2,7 +2,12 @@ import { test } from '../../../stub/render'
2
2
3
3
describe ( 'filters/object' , function ( ) {
4
4
describe ( 'default' , function ( ) {
5
- it ( 'should use default when falsy' , ( ) => test ( '{{false |default: "a"}}' , 'a' ) )
6
- it ( 'should not use default when truthy' , ( ) => test ( '{{true |default: "a"}}' , 'true' ) )
5
+ it ( 'false should use default' , ( ) => test ( '{{false | default: "a"}}' , 'a' ) )
6
+ it ( 'empty string should use default' , ( ) => test ( '{{"" | default: "a"}}' , 'a' ) )
7
+ it ( 'non-empty string should not use default' , ( ) => test ( '{{" " | default: "a"}}' , ' ' ) )
8
+ it ( 'nil should use default' , ( ) => test ( '{{nil | default: "a"}}' , 'a' ) )
9
+ it ( 'undefined should use default' , ( ) => test ( '{{not_defined | default: "a"}}' , 'a' ) )
10
+ it ( 'true should not use default' , ( ) => test ( '{{true | default: "a"}}' , 'true' ) )
11
+ it ( '0 should not use default' , ( ) => test ( '{{0 | default: "a"}}' , '0' ) )
7
12
} )
8
13
} )
You can’t perform that action at this time.
0 commit comments