Skip to content

Commit

Permalink
refactor: use standard transform name
Browse files Browse the repository at this point in the history
  • Loading branch information
Aarebecca committed Oct 8, 2024
1 parent 3d8a839 commit 1196edd
Show file tree
Hide file tree
Showing 5 changed files with 102 additions and 102 deletions.
76 changes: 38 additions & 38 deletions __tests__/unit/css/parser/transform.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ describe('Property Transform', () => {
expect(result[1].d[0].toString()).toBe('3');
expect(result[1].d[1].toString()).toBe('-4');

expect(result[2].t).toBe('scalex');
expect(result[2].t).toBe('scaleX');
expect(result[2].d[0].toString()).toBe('5');

expect(result[3].t).toBe('scaley');
expect(result[3].t).toBe('scaleY');
expect(result[3].d[0].toString()).toBe('-1');

expect(result[4].t).toBe('scalez');
expect(result[4].t).toBe('scaleZ');
expect(result[4].d[0].toString()).toBe('-3');

result = parseTransform('scale3d(-2, 0, 7)');
Expand All @@ -46,11 +46,11 @@ describe('Property Transform', () => {
expect(result[0].d[0].toString()).toBe('10deg');
expect(result[1].t).toBe('rotate');
expect(result[1].d[0].toString()).toBe('1turn');
expect(result[2].t).toBe('rotatex');
expect(result[2].t).toBe('rotateX');
expect(result[2].d[0].toString()).toBe('0deg');
expect(result[3].t).toBe('rotatey');
expect(result[3].t).toBe('rotateY');
expect(result[3].d[0].toString()).toBe('1.5rad');
expect(result[4].t).toBe('rotatez');
expect(result[4].t).toBe('rotateZ');
expect(result[4].d[0].toString()).toBe('50grad');
expect(result[5].t).toBe('rotate3d');
expect(result[5].d[0].toString()).toBe('0');
Expand All @@ -68,25 +68,25 @@ describe('Property Transform', () => {
expect(result[1].d[0].toString()).toBe('0px');

result = parseTransform('translateX(10px) translateX(20%) translateX(0)');
expect(result[0].t).toBe('translatex');
expect(result[0].t).toBe('translateX');
expect(result[0].d[0].toString()).toBe('10px');
expect(result[1].t).toBe('translatex');
expect(result[1].t).toBe('translateX');
expect(result[1].d[0].toString()).toBe('20%');
expect(result[2].t).toBe('translatex');
expect(result[2].t).toBe('translateX');
expect(result[2].d[0].toString()).toBe('0px');

result = parseTransform('translateY(10px) translateY(20%) translateY(0)');
expect(result[0].t).toBe('translatey');
expect(result[0].t).toBe('translateY');
expect(result[0].d[0].toString()).toBe('10px');
expect(result[1].t).toBe('translatey');
expect(result[1].t).toBe('translateY');
expect(result[1].d[0].toString()).toBe('20%');
expect(result[2].t).toBe('translatey');
expect(result[2].t).toBe('translateY');
expect(result[2].d[0].toString()).toBe('0px');

result = parseTransform('translateZ(10px) translateZ(0)');
expect(result[0].t).toBe('translatez');
expect(result[0].t).toBe('translateZ');
expect(result[0].d[0].toString()).toBe('10px');
expect(result[1].t).toBe('translatez');
expect(result[1].t).toBe('translateZ');
expect(result[1].d[0].toString()).toBe('0px');

result = parseTransform(
Expand Down Expand Up @@ -200,15 +200,15 @@ describe('Property Transform', () => {
expect(result).toStrictEqual([
{
d: [CSS.rad(0.312)],
t: 'skewx',
t: 'skewX',
},
]);

result = parseTransform('skewY(.312rad)');
expect(result).toStrictEqual([
{
d: [CSS.rad(0.312)],
t: 'skewy',
t: 'skewY',
},
]);
});
Expand All @@ -224,48 +224,48 @@ describe('Property Transform', () => {
expect(format([[1, 2]])).toBe('scale(1,2)');
});

it('should merge transforms(scalex & scaley) correctly', () => {
it('should merge transforms(scaleX & scaleY) correctly', () => {
const [left, right, format] = mergeTransforms(
[{ t: 'scalex', d: [new CSSUnitValue(2)] }],
[{ t: 'scaley', d: [new CSSUnitValue(3)] }],
[{ t: 'scaleX', d: [new CSSUnitValue(2)] }],
[{ t: 'scaleY', d: [new CSSUnitValue(3)] }],
null,
);
expect(left).toStrictEqual([[2, 1]]);
expect(right).toStrictEqual([[1, 3]]);
expect(format([[1, 2]])).toBe('scale(1,2)');
});

it('should merge transforms(scale & scaley) correctly', () => {
it('should merge transforms(scale & scaleY) correctly', () => {
const [left, right, format] = mergeTransforms(
[{ t: 'scale', d: [new CSSUnitValue(1), new CSSUnitValue(2)] }],
[{ t: 'scaley', d: [new CSSUnitValue(3)] }],
[{ t: 'scaleY', d: [new CSSUnitValue(3)] }],
null,
);
expect(left).toStrictEqual([[1, 2]]);
expect(right).toStrictEqual([[1, 3]]);
expect(format([[1, 2]])).toBe('scale(1,2)');
});

it('should merge transforms(scale & scaley) correctly', () => {
it('should merge transforms(scale & scaleY) correctly', () => {
const [left, right, format] = mergeTransforms(
[{ t: 'scale', d: [new CSSUnitValue(0.0001), new CSSUnitValue(1)] }],
[{ t: 'scaley', d: [new CSSUnitValue(1)] }],
[{ t: 'scaleY', d: [new CSSUnitValue(1)] }],
null,
);
expect(left).toStrictEqual([[0.0001, 1]]);
expect(right).toStrictEqual([[1, 1]]);
expect(format([[0.0001, 1]])).toBe('scale(0.0001,1)');
});

it('should merge transforms(translatex) correctly', () => {
it('should merge transforms(translateX) correctly', () => {
const [left, right, format] = mergeTransforms(
[{ t: 'translatex', d: [new CSSUnitValue(1, 'px')] }],
[{ t: 'translatex', d: [new CSSUnitValue(10, 'px')] }],
[{ t: 'translateX', d: [new CSSUnitValue(1, 'px')] }],
[{ t: 'translateX', d: [new CSSUnitValue(10, 'px')] }],
null,
);
expect(left).toStrictEqual([[1]]);
expect(right).toStrictEqual([[10]]);
expect(format([[10]])).toBe('translatex(10px)');
expect(format([[10]])).toBe('translateX(10px)');
});

it('should merge transforms(translate) correctly', () => {
Expand Down Expand Up @@ -347,39 +347,39 @@ describe('Property Transform', () => {
[
{
d: [CSS.deg(15)],
t: 'skewx',
t: 'skewX',
},
],
[
{
d: [CSS.deg(30)],
t: 'skewx',
t: 'skewX',
},
],
null,
);
expect(left).toStrictEqual([[15]]);
expect(right).toStrictEqual([[30]]);
expect(format([[20]])).toBe('skewx(20deg)');
expect(format([[20]])).toBe('skewX(20deg)');

[left, right, format] = mergeTransforms(
[
{
d: [CSS.deg(15)],
t: 'skewy',
t: 'skewY',
},
],
[
{
d: [CSS.deg(30)],
t: 'skewy',
t: 'skewY',
},
],
null,
);
expect(left).toStrictEqual([[15]]);
expect(right).toStrictEqual([[30]]);
expect(format([[20]])).toBe('skewy(20deg)');
expect(format([[20]])).toBe('skewY(20deg)');

[left, right, format] = mergeTransforms(
[
Expand All @@ -391,7 +391,7 @@ describe('Property Transform', () => {
[
{
d: [CSS.deg(30)],
t: 'skewy',
t: 'skewY',
},
],
null,
Expand All @@ -410,7 +410,7 @@ describe('Property Transform', () => {
[
{
d: [CSS.deg(30)],
t: 'skewx',
t: 'skewX',
},
],
null,
Expand All @@ -424,14 +424,14 @@ describe('Property Transform', () => {
const [left, right, format] = mergeTransforms(
[
{
t: 'translatey',
t: 'translateY',
d: [new CSSUnitValue(0, 'px')],
},
{ t: 'scale', d: [new CSSUnitValue(0.7), new CSSUnitValue(0.7)] },
],
[
{
t: 'translatey',
t: 'translateY',
d: [new CSSUnitValue(0, 'px')],
},
],
Expand Down Expand Up @@ -464,7 +464,7 @@ describe('Property Transform', () => {
],
[
{
t: 'translatey',
t: 'translateY',
d: [new CSSUnitValue(0, 'px')],
},
],
Expand Down
18 changes: 9 additions & 9 deletions __tests__/unit/css/properties/transform.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ describe('CSSPropertyTransform', () => {
// expect(circle.getLocalPosition()).toStrictEqual([20, 0, 0]);
// used = circle.computedStyleMap().get('transform') as ParsedTransform[];
// expect(used.length).toBe(1);
// expect(used[0].t).toBe('translatex');
// expect(used[0].t).toBe('translateX');
// expect(used[0].d.length).toBe(1);
// expect(used[0].d[0].equals(CSS.px(20))).toBeTruthy();

Expand All @@ -69,7 +69,7 @@ describe('CSSPropertyTransform', () => {
// expect(circle.getLocalPosition()).toStrictEqual([0, 20, 0]);
// used = circle.computedStyleMap().get('transform') as ParsedTransform[];
// expect(used.length).toBe(1);
// expect(used[0].t).toBe('translatey');
// expect(used[0].t).toBe('translateY');
// expect(used[0].d.length).toBe(1);
// expect(used[0].d[0].equals(CSS.px(20))).toBeTruthy();

Expand All @@ -78,7 +78,7 @@ describe('CSSPropertyTransform', () => {
// expect(circle.getLocalPosition()).toStrictEqual([0, 0, 20]);
// used = circle.computedStyleMap().get('transform') as ParsedTransform[];
// expect(used.length).toBe(1);
// expect(used[0].t).toBe('translatez');
// expect(used[0].t).toBe('translateZ');
// expect(used[0].d.length).toBe(1);
// expect(used[0].d[0].equals(CSS.px(20))).toBeTruthy();

Expand All @@ -98,7 +98,7 @@ describe('CSSPropertyTransform', () => {
// expect(circle.getLocalPosition()).toStrictEqual([0, 0, 0]);
// used = circle.computedStyleMap().get('transform') as ParsedTransform[];
// expect(used.length).toBe(1);
// expect(used[0].t).toBe('scalex');
// expect(used[0].t).toBe('scaleX');
// expect(used[0].d.length).toBe(1);
// expect(used[0].d[0].equals(CSS.number(2))).toBeTruthy();

Expand All @@ -107,7 +107,7 @@ describe('CSSPropertyTransform', () => {
// expect(circle.getLocalPosition()).toStrictEqual([0, 0, 0]);
// used = circle.computedStyleMap().get('transform') as ParsedTransform[];
// expect(used.length).toBe(1);
// expect(used[0].t).toBe('scaley');
// expect(used[0].t).toBe('scaleY');
// expect(used[0].d.length).toBe(1);
// expect(used[0].d[0].equals(CSS.number(2))).toBeTruthy();

Expand All @@ -116,7 +116,7 @@ describe('CSSPropertyTransform', () => {
// expect(circle.getLocalPosition()).toStrictEqual([0, 0, 0]);
// used = circle.computedStyleMap().get('transform') as ParsedTransform[];
// expect(used.length).toBe(1);
// expect(used[0].t).toBe('scalez');
// expect(used[0].t).toBe('scaleZ');
// expect(used[0].d.length).toBe(1);
// expect(used[0].d[0].equals(CSS.number(2))).toBeTruthy();

Expand Down Expand Up @@ -192,7 +192,7 @@ describe('CSSPropertyTransform', () => {
// expect(circle.getLocalPosition()).toStrictEqual([0, 0, 0]);
// used = circle.computedStyleMap().get('transform') as ParsedTransform[];
// expect(used.length).toBe(1);
// expect(used[0].t).toBe('rotatex');
// expect(used[0].t).toBe('rotateX');
// expect(used[0].d.length).toBe(1);
// expect(used[0].d[0].equals(CSS.deg(30))).toBeTruthy();

Expand All @@ -201,7 +201,7 @@ describe('CSSPropertyTransform', () => {
// expect(circle.getLocalPosition()).toStrictEqual([0, 0, 0]);
// used = circle.computedStyleMap().get('transform') as ParsedTransform[];
// expect(used.length).toBe(1);
// expect(used[0].t).toBe('rotatey');
// expect(used[0].t).toBe('rotateY');
// expect(used[0].d.length).toBe(1);
// expect(used[0].d[0].equals(CSS.deg(30))).toBeTruthy();

Expand All @@ -210,7 +210,7 @@ describe('CSSPropertyTransform', () => {
// expect(circle.getLocalPosition()).toStrictEqual([0, 0, 0]);
// used = circle.computedStyleMap().get('transform') as ParsedTransform[];
// expect(used.length).toBe(1);
// expect(used[0].t).toBe('rotatez');
// expect(used[0].t).toBe('rotateZ');
// expect(used[0].d.length).toBe(1);
// expect(used[0].d[0].equals(CSS.deg(30))).toBeTruthy();
// });
Expand Down
Loading

0 comments on commit 1196edd

Please sign in to comment.