FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

chore: update tests for x,y rotation · NativeScript/NativeScript@6da8c51 · GitHub

Repository navigation

Commit 6da8c51

Browse files
committed
chore: update tests for x,y rotation
1 parent 50d6f71 commit 6da8c51

2 files changed

Lines changed: 15 additions & 17 deletions

File tree

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

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { View } from "../core/view";
1212
// Types.
1313
import { Color } from "../../color";
1414
import { isEnabled as traceEnabled, write as traceWrite, categories as traceCategories, messageType as traceType } from "../../trace";
15+
import { PercentLength } from "../styling/style-properties";
1516

1617
export { Color, traceEnabled, traceWrite, traceCategories, traceType };
1718

@@ -161,22 +162,19 @@ export abstract class AnimationBase implements AnimationBaseDefinition {
161162
continue;
162163
}
163164

164-
if (item === Properties.opacity ||
165+
if ((item === Properties.opacity ||
165166
item === "duration" ||
166167
item === "delay" ||
167-
item === "iterations") {
168-
169-
if (typeof value !== "number") {
170-
throw new Error(`Property ${item} must be valid number. Value: ${value}`);
171-
}
172-
173-
} else if (item === Properties.scale || item === Properties.translate) {
174-
const pair = <Pair>value;
175-
if (typeof pair.x !== "number" || typeof pair.y !== "number") {
176-
throw new Error(`Property ${item} must be valid Pair. Value: ${value}`);
177-
}
168+
item === "iterations") && typeof value !== "number") {
169+
throw new Error(`Property ${item} must be valid number. Value: ${value}`);
170+
} else if ((item === Properties.scale || item === Properties.translate) &&
171+
(typeof (<Pair>value).x !== "number" || typeof (<Pair>value).y !== "number")) {
172+
throw new Error(`Property ${item} must be valid Pair. Value: ${value}`);
178173
} else if (item === Properties.backgroundColor && !Color.isValid(animationDefinition.backgroundColor)) {
179174
throw new Error(`Property ${item} must be valid color. Value: ${value}`);
175+
} else if (item === Properties.width || item === Properties.height) {
176+
// Coerce input into a PercentLength object in case it's a string.
177+
animationDefinition[item] = PercentLength.parse(<any>value);
180178
} else if (item === Properties.rotate) {
181179
const rotate: number | Point3D = value;
182180
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)

Back | FazBrowse Home | New Git URL