UNPKG

2.56 kBJavaScriptView Raw
1import { projAppJS, simpleAppJS, reduxAppJS } from './mocks/app'
2import { simplePageJS, reduxPageJS } from './mocks/page'
3
4const {transformJSCode} = require('../src/rn/transformJS')
5const _ = require('lodash')
6
7const filePath = '/Users/chengshuai/Taro/taro-quick-start/src/app.js'
8const tsFilePath = '/Users/chengshuai/Taro/taro-quick-start/src/app.ts'
9const projectConfig = require('./mocks/config')(_.merge)
10
11describe('RN', function () {
12 describe('transformJSCode', function () {
13 describe('app.js', function () {
14 it('should transform projAppJS conrrect', function () {
15 const transformResult = transformJSCode(
16 {
17 code: projAppJS,
18 filePath,
19 isEntryFile: true,
20 projectConfig
21 }
22 )
23 expect(transformResult).toMatchSnapshot()
24 })
25
26 it('should transform simpleAppJS conrrect', function () {
27 const transformResult = transformJSCode(
28 {
29 code: simpleAppJS,
30 filePath,
31 isEntryFile: true,
32 projectConfig
33 }
34 )
35 expect(transformResult).toMatchSnapshot()
36 })
37
38 it('should transform reduxAppJS conrrect', function () {
39 const transformResult = transformJSCode(
40 {
41 code: reduxAppJS,
42 filePath,
43 isEntryFile: true,
44 projectConfig
45 }
46 )
47 expect(transformResult).toMatchSnapshot()
48 })
49
50 it('should transform appx.ts conrrect', function () {
51 const transformResult = transformJSCode(
52 {
53 code: simpleAppJS,
54 filePath: tsFilePath,
55 isEntryFile: true,
56 projectConfig
57 }
58 )
59 expect(transformResult).toMatchSnapshot()
60 })
61 })
62 describe('page.js', function () {
63 it('should transform simplePageJS conrrect', function () {
64 const transformResult = transformJSCode(
65 {
66 code: simplePageJS,
67 filePath,
68 isEntryFile: false,
69 projectConfig
70 }
71 )
72 expect(transformResult).toMatchSnapshot()
73 })
74
75 it('should transform reduxPageJS conrrect , with decorator', function () {
76 const transformResult = transformJSCode(
77 {
78 code: reduxPageJS,
79 filePath,
80 isEntryFile: false,
81 projectConfig
82 }
83 )
84 expect(transformResult).toMatchSnapshot()
85 })
86 })
87 })
88
89 describe('compileDepStyles', function () {
90
91 })
92})