File tree Expand file tree Collapse file tree 2 files changed +42
-0
lines changed Expand file tree Collapse file tree 2 files changed +42
-0
lines changed Original file line number Diff line number Diff line change 5555 "karma-mocha" : " ^1.3.0" ,
5656 "karma-webpack" : " ^3.0.5" ,
5757 "mocha" : " ^5.2.0" ,
58+ "pretty-format" : " ^26.0.1" ,
5859 "webpack" : " ^4.41.2" ,
5960 "webpack-cli" : " ^3.3.10"
6061 },
Original file line number Diff line number Diff line change 1+ const prettyFormat = require ( 'pretty-format' )
2+ const snapshotPlugin = require ( '../../src/jest-snapshot-plugin' )
3+
4+ const testSymbol =
5+ typeof Symbol === 'function' && Symbol . for
6+ ? Symbol . for ( 'j-component.json' )
7+ : 0xd846fe
8+
9+ test ( 'snapshot' , ( ) => {
10+ const str = prettyFormat (
11+ {
12+ $$typeof : testSymbol ,
13+ tagName : 'view' ,
14+ attrs : [ { name : 'class' , value : 'weui' } ] ,
15+ event : {
16+ tap : {
17+ handler : 'onTap' ,
18+ id : 0 ,
19+ isCapture : true ,
20+ isCatch : false ,
21+ isMutated : true ,
22+ name : 'tap' ,
23+ } ,
24+ } ,
25+ children : [
26+ 'hello ' ,
27+ {
28+ $$typeof : testSymbol ,
29+ tagName : 'view' ,
30+ attrs : [ ] ,
31+ event : { } ,
32+ children : [ ] ,
33+ } ,
34+ ] ,
35+ } ,
36+ { plugins : [ snapshotPlugin ] }
37+ )
38+ expect ( str ) . toEqual (
39+ '<view\n class="weui"\n capture-mut-bind:tap="onTap"\n>\n hello \n <view />\n</view>'
40+ )
41+ } )
You can’t perform that action at this time.
0 commit comments