fix(input): checked attr can be an empty string or no value

This commit is contained in:
Adam Bradley
2016-01-26 11:11:48 -06:00
parent 42f6b1056f
commit e76b55994c
13 changed files with 291 additions and 223 deletions

View File

@ -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);