Visitar URL original
chore: update tests for x,y rotation · NativeScript/NativeScript@170ef2c · GitHub
Skip to content

Commit 170ef2c

Browse files
committed
chore: update tests for x,y rotation
1 parent 5b2e9ce commit 170ef2c

2 files changed

Lines changed: 14 additions & 21 deletions

File tree

‎nativescript-core/ui/animation/animation-common.ts‎

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,11 @@ import {
1111

1212
// Requires.
1313
import { Color } from "../../color";
14-
<<<<<<< HEAD
1514
import {
1615
isEnabled as traceEnabled, write as traceWrite,
1716
categories as traceCategories, messageType as traceType
1817
} from "../../trace";
1918
import { PercentLength } from "../styling/style-properties";
20-
=======
21-
import { isEnabled as traceEnabled, write as traceWrite, categories as traceCategories, messageType as traceType } from "../../trace";
22-
>>>>>>> chore: unused import cleanup
2319

2420
export { Color, traceEnabled, traceWrite, traceCategories, traceType };
2521
export * from "./animation-interfaces";
@@ -160,22 +156,19 @@ export abstract class AnimationBase implements AnimationBaseDefinition {
160156
continue;
161157
}
162158

163-
if (item === Properties.opacity ||
159+
if ((item === Properties.opacity ||
164160
item === "duration" ||
165161
item === "delay" ||
166-
item === "iterations") {
167-
168-
if (typeof value !== "number") {
169-
throw new Error(`Property ${item} must be valid number. Value: ${value}`);
170-
}
171-
172-
} else if (item === Properties.scale || item === Properties.translate) {
173-
const pair = <Pair>value;
174-
if (typeof pair.x !== "number" || typeof pair.y !== "number") {
175-
throw new Error(`Property ${item} must be valid Pair. Value: ${value}`);
176-
}
162+
item === "iterations") && typeof value !== "number") {
163+
throw new Error(`Property ${item} must be valid number. Value: ${value}`);
164+
} else if ((item === Properties.scale || item === Properties.translate) &&
165+
(typeof (<Pair>value).x !== "number" || typeof (<Pair>value).y !== "number")) {
166+
throw new Error(`Property ${item} must be valid Pair. Value: ${value}`);
177167
} else if (item === Properties.backgroundColor && !Color.isValid(animationDefinition.backgroundColor)) {
178168
throw new Error(`Property ${item} must be valid color. Value: ${value}`);
169+
} else if (item === Properties.width || item === Properties.height) {
170+
// Coerce input into a PercentLength object in case it's a string.
171+
animationDefinition[item] = PercentLength.parse(<any>value);
179172
} else if (item === Properties.rotate) {
180173
const rotate: number | Point3D = value;
181174
if ((typeof rotate !== "number") &&

‎tests/app/ui/animation/css-animation-tests.ts‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ export function test_ReadTransformAllSet() {
122122
const animation = createAnimationFromCSS(css, "test");
123123
const { rotate, scale, translate } = getTransformsValues(animation.keyframes[0].declarations);
124124

125-
TKUnit.assertAreClose(rotate, 10, DELTA);
125+
TKUnit.assertAreClose(rotate.z, 10, DELTA);
126126

127127
TKUnit.assertAreClose(scale.x, 5, SCALE_DELTA);
128128
TKUnit.assertAreClose(scale.y, 1, SCALE_DELTA);
@@ -136,7 +136,7 @@ export function test_ReadTransformNone() {
136136
const animation = createAnimationFromCSS(css, "test");
137137
const { rotate, scale, translate } = getTransformsValues(animation.keyframes[0].declarations);
138138

139-
TKUnit.assertEqual(rotate, 0);
139+
TKUnit.assertEqual(rotate.z, 0);
140140

141141
TKUnit.assertEqual(scale.x, 1);
142142
TKUnit.assertEqual(scale.y, 1);
@@ -271,7 +271,7 @@ export function test_ReadRotate() {
271271
const { rotate } = getTransforms(animation.keyframes[0].declarations);
272272

273273
TKUnit.assertEqual(rotate.property, "rotate");
274-
TKUnit.assertAreClose(rotate.value, 5, DELTA);
274+
TKUnit.assertAreClose(rotate.value.z, 5, DELTA);
275275
}
276276

277277
export function test_ReadRotateDeg() {
@@ -280,7 +280,7 @@ export function test_ReadRotateDeg() {
280280
const { rotate } = getTransforms(animation.keyframes[0].declarations);
281281

282282
TKUnit.assertEqual(rotate.property, "rotate");
283-
TKUnit.assertAreClose(rotate.value, 45, DELTA);
283+
TKUnit.assertAreClose(rotate.value.z, 45, DELTA);
284284
}
285285

286286
export function test_ReadRotateRad() {
@@ -289,7 +289,7 @@ export function test_ReadRotateRad() {
289289
const { rotate } = getTransforms(animation.keyframes[0].declarations);
290290

291291
TKUnit.assertEqual(rotate.property, "rotate");
292-
TKUnit.assertAreClose(rotate.value, 45, DELTA);
292+
TKUnit.assertAreClose(rotate.value.z, 45, DELTA);
293293
}
294294

295295
export function test_ReadAnimationWithUnsortedKeyframes() {

0 commit comments

Comments
 (0)