mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-20 20:33:32 +08:00
fix(input): checked attr can be an empty string or no value
This commit is contained in:
@ -3,6 +3,53 @@ import * as util from 'ionic/util';
|
||||
export function run() {
|
||||
describe('extend', function() {
|
||||
|
||||
describe('isTrueProperty', function() {
|
||||
|
||||
it('should be true from boolean true', () => {
|
||||
expect(util.isTrueProperty(true)).toBe(true);
|
||||
});
|
||||
|
||||
it('should be true from string "true"', () => {
|
||||
expect(util.isTrueProperty('true')).toBe(true);
|
||||
expect(util.isTrueProperty('TRUE')).toBe(true);
|
||||
expect(util.isTrueProperty(' true ')).toBe(true);
|
||||
});
|
||||
|
||||
it('should be true from empty string ""', () => {
|
||||
expect(util.isTrueProperty('')).toBe(true);
|
||||
expect(util.isTrueProperty(' ')).toBe(true);
|
||||
});
|
||||
|
||||
it('should be true from number greater than zero', () => {
|
||||
expect(util.isTrueProperty(1)).toBe(true);
|
||||
expect(util.isTrueProperty(999)).toBe(true);
|
||||
});
|
||||
|
||||
it('should be false from boolean false', () => {
|
||||
expect(util.isTrueProperty(false)).toBe(false);
|
||||
});
|
||||
|
||||
it('should be false from null', () => {
|
||||
expect(util.isTrueProperty(null)).toBe(false);
|
||||
});
|
||||
|
||||
it('should be false from undefined', () => {
|
||||
expect(util.isTrueProperty(undefined)).toBe(false);
|
||||
});
|
||||
|
||||
it('should be false from string "false"', () => {
|
||||
expect(util.isTrueProperty('false')).toBe(false);
|
||||
expect(util.isTrueProperty(' FALSE ')).toBe(false);
|
||||
expect(util.isTrueProperty('doesnt actually matter')).toBe(false);
|
||||
});
|
||||
|
||||
it('should be false from number less than 1', () => {
|
||||
expect(util.isTrueProperty(0)).toBe(false);
|
||||
expect(util.isTrueProperty(-1)).toBe(false);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
it('should extend simple', () => {
|
||||
var obj = { a: '0', c: '0' };
|
||||
expect( util.assign(obj, { a: '1', b: '2' }) ).toBe(obj);
|
||||
|
Reference in New Issue
Block a user