postcss-pxtransform 3.7.0-beta.3 → 3.7.0-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/__tests__/index.test.js +79 -0
- package/index.js +1 -0
- package/package.json +1 -1
package/__tests__/index.test.js
CHANGED
|
@@ -523,6 +523,17 @@ describe('platform 为 weapp', () => {
|
|
|
523
523
|
const processed = postcss(px2rem(options)).process(rules).css
|
|
524
524
|
expect(processed).toBe(expected)
|
|
525
525
|
})
|
|
526
|
+
|
|
527
|
+
it('{platform: \'weapp\', designWidth: 375} ', () => {
|
|
528
|
+
const rules = 'h1 {margin: 0 0 20px;font-size: 40px;line-height: 1.2;}'
|
|
529
|
+
const expected = 'h1 {margin: 0 0 40rpx;font-size: 80rpx;line-height: 1.2;}'
|
|
530
|
+
const options = {
|
|
531
|
+
platform: 'weapp',
|
|
532
|
+
designWidth: 375
|
|
533
|
+
}
|
|
534
|
+
const processed = postcss(px2rem(options)).process(rules).css
|
|
535
|
+
expect(processed).toBe(expected)
|
|
536
|
+
})
|
|
526
537
|
})
|
|
527
538
|
|
|
528
539
|
describe('platform 为 weapp, targetUnit 为 rem', () => {
|
|
@@ -549,6 +560,18 @@ describe('platform 为 weapp, targetUnit 为 rem', () => {
|
|
|
549
560
|
const processed = postcss(px2rem(options)).process(rules).css
|
|
550
561
|
expect(processed).toBe(expected)
|
|
551
562
|
})
|
|
563
|
+
|
|
564
|
+
it('{platform: \'weapp\', designWidth: 375, targetUnit: \'rem\'} ', () => {
|
|
565
|
+
const rules = 'h1 {margin: 0 0 20px;font-size: 40px;line-height: 1.2;}'
|
|
566
|
+
const expected = 'h1 {margin: 0 0 1rem;font-size: 2rem;line-height: 1.2;}'
|
|
567
|
+
const options = {
|
|
568
|
+
platform: 'weapp',
|
|
569
|
+
designWidth: 375,
|
|
570
|
+
targetUnit: 'rem'
|
|
571
|
+
}
|
|
572
|
+
const processed = postcss(px2rem(options)).process(rules).css
|
|
573
|
+
expect(processed).toBe(expected)
|
|
574
|
+
})
|
|
552
575
|
})
|
|
553
576
|
|
|
554
577
|
describe('platform 为 weapp, targetUnit 为 px', () => {
|
|
@@ -575,6 +598,18 @@ describe('platform 为 weapp, targetUnit 为 px', () => {
|
|
|
575
598
|
const processed = postcss(px2rem(options)).process(rules).css
|
|
576
599
|
expect(processed).toBe(expected)
|
|
577
600
|
})
|
|
601
|
+
|
|
602
|
+
it('{platform: \'weapp\', designWidth: 375, targetUnit: \'px\'} ', () => {
|
|
603
|
+
const rules = 'h1 {margin: 0 0 20px;font-size: 40px;line-height: 1.2;}'
|
|
604
|
+
const expected = 'h1 {margin: 0 0 20px;font-size: 40px;line-height: 1.2;}'
|
|
605
|
+
const options = {
|
|
606
|
+
platform: 'weapp',
|
|
607
|
+
designWidth: 375,
|
|
608
|
+
targetUnit: 'px'
|
|
609
|
+
}
|
|
610
|
+
const processed = postcss(px2rem(options)).process(rules).css
|
|
611
|
+
expect(processed).toBe(expected)
|
|
612
|
+
})
|
|
578
613
|
})
|
|
579
614
|
|
|
580
615
|
describe('platform 为 h5', () => {
|
|
@@ -599,6 +634,17 @@ describe('platform 为 h5', () => {
|
|
|
599
634
|
const processed = postcss(px2rem(options)).process(rules).css
|
|
600
635
|
expect(processed).toBe(expected)
|
|
601
636
|
})
|
|
637
|
+
|
|
638
|
+
it('{platform: \'h5\', designWidth: 375} ', () => {
|
|
639
|
+
const rules = 'h1 {margin: 0 0 20px;font-size: 40Px;line-height: 1.2;}'
|
|
640
|
+
const expected = 'h1 {margin: 0 0 1rem;font-size: 40Px;line-height: 1.2;}'
|
|
641
|
+
const options = {
|
|
642
|
+
platform: 'h5',
|
|
643
|
+
designWidth: 375
|
|
644
|
+
}
|
|
645
|
+
const processed = postcss(px2rem(options)).process(rules).css
|
|
646
|
+
expect(processed).toBe(expected)
|
|
647
|
+
})
|
|
602
648
|
})
|
|
603
649
|
|
|
604
650
|
describe('platform 为 h5, targetUnit 为 px', () => {
|
|
@@ -625,6 +671,18 @@ describe('platform 为 h5, targetUnit 为 px', () => {
|
|
|
625
671
|
const processed = postcss(px2rem(options)).process(rules).css
|
|
626
672
|
expect(processed).toBe(expected)
|
|
627
673
|
})
|
|
674
|
+
|
|
675
|
+
it('{platform: \'h5\', designWidth: 375, targetUnit: \'px\'} ', () => {
|
|
676
|
+
const rules = 'h1 {margin: 0 0 20px;font-size: 40Px;line-height: 1.2;}'
|
|
677
|
+
const expected = 'h1 {margin: 0 0 20px;font-size: 40Px;line-height: 1.2;}'
|
|
678
|
+
const options = {
|
|
679
|
+
platform: 'h5',
|
|
680
|
+
designWidth: 375,
|
|
681
|
+
targetUnit: 'px'
|
|
682
|
+
}
|
|
683
|
+
const processed = postcss(px2rem(options)).process(rules).css
|
|
684
|
+
expect(processed).toBe(expected)
|
|
685
|
+
})
|
|
628
686
|
})
|
|
629
687
|
|
|
630
688
|
describe('platform 为 h5,文件头部带注释的不转换', () => {
|
|
@@ -719,6 +777,16 @@ describe('rpx 单位转换', () => {
|
|
|
719
777
|
const processed = postcss(px2rem(options)).process(rules).css
|
|
720
778
|
expect(processed).toBe('h1 {margin: 0 0 0.585rem;font-size: 40Px;line-height: 1.2;} .test{}')
|
|
721
779
|
})
|
|
780
|
+
|
|
781
|
+
it('{platform: \'weapp\', designWidth: 375} ', () => {
|
|
782
|
+
const rules = 'h1 {margin: 0 0 20rpx;font-size: 40Px;line-height: 1.2;} .test{}'
|
|
783
|
+
const options = {
|
|
784
|
+
platform: 'weapp',
|
|
785
|
+
designWidth: 375
|
|
786
|
+
}
|
|
787
|
+
const processed = postcss(px2rem(options)).process(rules).css
|
|
788
|
+
expect(processed).toBe('h1 {margin: 0 0 20rpx;font-size: 40Px;line-height: 1.2;} .test{}')
|
|
789
|
+
})
|
|
722
790
|
})
|
|
723
791
|
|
|
724
792
|
describe('vw 单位转换', () => {
|
|
@@ -754,6 +822,17 @@ describe('vw 单位转换', () => {
|
|
|
754
822
|
const processed = postcss(px2rem(options)).process(rules).css
|
|
755
823
|
expect(processed).toBe('h1 {margin: 0 0 50vw;font-size: 40Px;line-height: 1.2;} .test{}')
|
|
756
824
|
})
|
|
825
|
+
|
|
826
|
+
it('{platform: \'h5\', designWidth: 375} ', () => {
|
|
827
|
+
const rules = 'h1 {margin: 0 0 320px;font-size: 40Px;line-height: 1.2;} .test{}'
|
|
828
|
+
const options = {
|
|
829
|
+
platform: 'h5',
|
|
830
|
+
designWidth: 375,
|
|
831
|
+
targetUnit: 'vw'
|
|
832
|
+
}
|
|
833
|
+
const processed = postcss(px2rem(options)).process(rules).css
|
|
834
|
+
expect(processed).toBe('h1 {margin: 0 0 85.33333vw;font-size: 40Px;line-height: 1.2;} .test{}')
|
|
835
|
+
})
|
|
757
836
|
})
|
|
758
837
|
|
|
759
838
|
describe('platform 为 rn,适配', () => {
|
package/index.js
CHANGED