babel-plugin-transform-taroapi 3.6.7-alpha.0 → 3.6.7-alpha.1
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.spec.ts
CHANGED
|
@@ -25,7 +25,7 @@ const getNamedImports = (importSpecifiers: (t.ImportSpecifier | t.ImportDefaultS
|
|
|
25
25
|
const babelTransform = (code = '') => babel.transform(code, { ast: true, configFile: false, plugins: [pluginOptions] })
|
|
26
26
|
|
|
27
27
|
describe('babel-plugin-transform-taroapi', () => {
|
|
28
|
-
test
|
|
28
|
+
test('should work!', function () {
|
|
29
29
|
const code = `
|
|
30
30
|
import Taro, { setStorage, initPxTransform, param } from '${packageName}';
|
|
31
31
|
initPxTransform(param)
|
|
@@ -39,7 +39,7 @@ describe('babel-plugin-transform-taroapi', () => {
|
|
|
39
39
|
expect(result?.code).toMatchSnapshot()
|
|
40
40
|
})
|
|
41
41
|
|
|
42
|
-
test
|
|
42
|
+
test('should leave other apis untouched', function () {
|
|
43
43
|
const code = `
|
|
44
44
|
import Taro from '${packageName}'
|
|
45
45
|
Taro.noop
|
|
@@ -68,7 +68,7 @@ describe('babel-plugin-transform-taroapi', () => {
|
|
|
68
68
|
expect((body[1].expression as t.MemberExpression)).toMatchObject(obj)
|
|
69
69
|
})
|
|
70
70
|
|
|
71
|
-
test
|
|
71
|
+
test('should move static apis under "Taro"', function () {
|
|
72
72
|
const code = `
|
|
73
73
|
import { noop } from '${packageName}';
|
|
74
74
|
noop;
|
|
@@ -96,7 +96,7 @@ describe('babel-plugin-transform-taroapi', () => {
|
|
|
96
96
|
))
|
|
97
97
|
})
|
|
98
98
|
|
|
99
|
-
test
|
|
99
|
+
test('should not import taro duplicity', function () {
|
|
100
100
|
const code = `
|
|
101
101
|
import { Component } from '${packageName}';
|
|
102
102
|
import Taro from '${packageName}';
|
|
@@ -114,7 +114,7 @@ describe('babel-plugin-transform-taroapi', () => {
|
|
|
114
114
|
expect(t.isExpressionStatement(body[2])).toBeTruthy()
|
|
115
115
|
})
|
|
116
116
|
|
|
117
|
-
test
|
|
117
|
+
test('should not go wrong when using an api twice', function () {
|
|
118
118
|
const code = `
|
|
119
119
|
import Taro from '${packageName}';
|
|
120
120
|
const animation = Taro.createAnimation({
|
|
@@ -132,7 +132,7 @@ describe('babel-plugin-transform-taroapi', () => {
|
|
|
132
132
|
}).not.toThrowError()
|
|
133
133
|
})
|
|
134
134
|
|
|
135
|
-
test
|
|
135
|
+
test('should preserve default imports', function () {
|
|
136
136
|
const code = `
|
|
137
137
|
import Taro from '${packageName}'
|
|
138
138
|
console.log(Taro)
|
|
@@ -141,7 +141,7 @@ describe('babel-plugin-transform-taroapi', () => {
|
|
|
141
141
|
expect(result?.code).toMatchSnapshot()
|
|
142
142
|
})
|
|
143
143
|
|
|
144
|
-
test
|
|
144
|
+
test('should preserve assignments in left hands', function () {
|
|
145
145
|
const code = `
|
|
146
146
|
import Taro from '${packageName}'
|
|
147
147
|
let animation
|
|
@@ -159,7 +159,7 @@ describe('babel-plugin-transform-taroapi', () => {
|
|
|
159
159
|
expect(result?.code).toMatchSnapshot()
|
|
160
160
|
})
|
|
161
161
|
|
|
162
|
-
test
|
|
162
|
+
test('should support rename of imported names', function () {
|
|
163
163
|
const code = `
|
|
164
164
|
// import { inject as mobxInject, observer as mobxObserver } from '@tarojs/mobx'
|
|
165
165
|
import { Component as TaroComponent } from '${packageName}';
|