mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-19 03:32:21 +08:00
test(): add init config and queryParam tests
This commit is contained in:
@ -12,7 +12,7 @@ export var CSS_PROP = function(docEle: HTMLElement) {
|
|||||||
var keys = ['webkitTransform', '-webkit-transform', 'webkit-transform', 'transform'];
|
var keys = ['webkitTransform', '-webkit-transform', 'webkit-transform', 'transform'];
|
||||||
|
|
||||||
for (i = 0; i < keys.length; i++) {
|
for (i = 0; i < keys.length; i++) {
|
||||||
if ((<any>docEle.style)[keys[i]] !== undefined) {
|
if ((docEle.style as any)[keys[i]] !== undefined) {
|
||||||
css.transformProp = keys[i];
|
css.transformProp = keys[i];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -21,7 +21,7 @@ export var CSS_PROP = function(docEle: HTMLElement) {
|
|||||||
// transition
|
// transition
|
||||||
keys = ['webkitTransition', 'transition'];
|
keys = ['webkitTransition', 'transition'];
|
||||||
for (i = 0; i < keys.length; i++) {
|
for (i = 0; i < keys.length; i++) {
|
||||||
if ((<any>docEle.style)[keys[i]] !== undefined) {
|
if ((docEle.style as any)[keys[i]] !== undefined) {
|
||||||
css.transitionProp = keys[i];
|
css.transitionProp = keys[i];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -11,9 +11,9 @@ export function renderDatetime(template: string, value: DatetimeData, locale: Lo
|
|||||||
FORMAT_KEYS.forEach((format, index) => {
|
FORMAT_KEYS.forEach((format, index) => {
|
||||||
if (template.indexOf(format.f) > -1) {
|
if (template.indexOf(format.f) > -1) {
|
||||||
var token = '{' + index + '}';
|
var token = '{' + index + '}';
|
||||||
var text = renderTextFormat(format.f, (<any>value)[format.k], value, locale);
|
var text = renderTextFormat(format.f, (value as any)[format.k], value, locale);
|
||||||
|
|
||||||
if (!hasText && text && (<any>value)[format.k]) {
|
if (!hasText && text && (value as any)[format.k]) {
|
||||||
hasText = true;
|
hasText = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -259,7 +259,7 @@ export function updateDate(existingData: DatetimeData, newData: any): boolean {
|
|||||||
// merge new values from the picker's selection
|
// merge new values from the picker's selection
|
||||||
// to the existing DatetimeData values
|
// to the existing DatetimeData values
|
||||||
for (var k in newData) {
|
for (var k in newData) {
|
||||||
(<any>existingData)[k] = newData[k].value;
|
(existingData as any)[k] = newData[k].value;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -271,7 +271,7 @@ export function updateDate(existingData: DatetimeData, newData: any): boolean {
|
|||||||
} else {
|
} else {
|
||||||
// blank data, clear everything out
|
// blank data, clear everything out
|
||||||
for (let k in existingData) {
|
for (let k in existingData) {
|
||||||
delete (<any>existingData)[k];
|
delete (existingData as any)[k];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@ -319,7 +319,7 @@ export function getValueFromFormat(date: DatetimeData, format: string) {
|
|||||||
if (format === FORMAT_hh || format === FORMAT_h) {
|
if (format === FORMAT_hh || format === FORMAT_h) {
|
||||||
return (date.hour > 12 ? date.hour - 12 : date.hour);
|
return (date.hour > 12 ? date.hour - 12 : date.hour);
|
||||||
}
|
}
|
||||||
return (<any>date)[convertFormatToKey(format)];
|
return (date as any)[convertFormatToKey(format)];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
8
packages/core/src/global/test/config-controller.spec.ts
Normal file
8
packages/core/src/global/test/config-controller.spec.ts
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
import { createConfigController } from '../config-controller';
|
||||||
|
|
||||||
|
describe('Config', () => {
|
||||||
|
it('should get a value from the config', () => {
|
||||||
|
let config = createConfigController({ name: 'Doc Brown' }, null);
|
||||||
|
expect(config.get('name')).toEqual('Doc Brown');
|
||||||
|
});
|
||||||
|
});
|
19
packages/core/src/global/test/query-param.spec.ts
Normal file
19
packages/core/src/global/test/query-param.spec.ts
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
import { queryParam } from '../platform-configs';
|
||||||
|
|
||||||
|
describe('QueryParam', () => {
|
||||||
|
it('should read the url for a queryParam', () => {
|
||||||
|
let qp = queryParam('?boolean=false', 'boolean');
|
||||||
|
expect(qp).toBeDefined();
|
||||||
|
expect(qp).toEqual('false');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should get the value of queryParam', () => {
|
||||||
|
let qp = queryParam('?keyValue=b', 'keyValue');
|
||||||
|
expect(qp).toEqual('b');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should show nullfor a queryParam this is not passed', () => {
|
||||||
|
let qp = queryParam('', 'ionicanimate');
|
||||||
|
expect(qp).toBeNull();
|
||||||
|
});
|
||||||
|
});
|
@ -155,7 +155,7 @@ export function applyStyles(elm: HTMLElement, styles: {[styleProp: string]: stri
|
|||||||
|
|
||||||
if (elm) {
|
if (elm) {
|
||||||
for (var i = 0; i < styleProps.length; i++) {
|
for (var i = 0; i < styleProps.length; i++) {
|
||||||
(<any>elm.style)[styleProps[i]] = styles[styleProps[i]];
|
(elm.style as any)[styleProps[i]] = styles[styleProps[i]];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user