Skip to content

Commit 0e8c329

Browse files
committed
remove remaining redundant tests
1 parent 8636c67 commit 0e8c329

File tree

1 file changed

+63
-222
lines changed

1 file changed

+63
-222
lines changed

packages/babel-plugin-component-annotate/test/test-plugin.test.ts

Lines changed: 63 additions & 222 deletions
Original file line numberDiff line numberDiff line change
@@ -1051,44 +1051,11 @@ export default PureComponentName;
10511051
expect(result?.code).toMatchSnapshot();
10521052
});
10531053

1054-
it("Bananas ignore components dataSentrySourceFile=nomatch dataSentryComponent=nomatch dataSentryElement=nomatch snapshot matches", () => {
1055-
const result = transform(BananasStandardInput, {
1056-
filename: "/filename-test.js",
1057-
configFile: false,
1058-
presets: ["@babel/preset-react"],
1059-
plugins: [[plugin, { native: true, ignoreComponents: [["nomatch.js", "nomatch", "nomatch"]] }]],
1060-
});
1061-
expect(result?.code).toMatchInlineSnapshot(`
1062-
"import React, { Component } from 'react';
1063-
import { Image } from 'react-native';
1064-
class Bananas extends Component {
1065-
render() {
1066-
let pic = {
1067-
uri: 'https://upload.wikimedia.org/wikipedia/commons/d/de/Bananavarieties.jpg'
1068-
};
1069-
return /*#__PURE__*/React.createElement(Image, {
1070-
source: pic,
1071-
style: {
1072-
width: 193,
1073-
height: 110,
1074-
marginTop: 10
1075-
},
1076-
fsClass: \\"test-class\\",
1077-
dataSentryElement: \\"Image\\",
1078-
dataSentryComponent: \\"Bananas\\",
1079-
dataSentrySourceFile: \\"filename-test.js\\"
1080-
});
1081-
}
1082-
}"
1083-
`);
1084-
});
1085-
1086-
it("ignore components dataSentrySourceFile=* dataSentryComponent=nomatch dataSentryElement=nomatch snapshot matches", () => {
1054+
it("Bananas incompatible plugin @react-navigation source snapshot matches", () => {
10871055
const result = transform(BananasStandardInput, {
1088-
filename: "/filename-test.js",
1089-
configFile: false,
1056+
filename: "test/node_modules/@react-navigation/core/filename-test.js",
10901057
presets: ["@babel/preset-react"],
1091-
plugins: [[plugin, { native: true, ignoreComponents: [["*", "nomatch", "nomatch"]] }]],
1058+
plugins: [[plugin, { native: true }]],
10921059
});
10931060
expect(result?.code).toMatchInlineSnapshot(`
10941061
"import React, { Component } from 'react';
@@ -1105,26 +1072,23 @@ it("ignore components dataSentrySourceFile=* dataSentryComponent=nomatch dataSen
11051072
height: 110,
11061073
marginTop: 10
11071074
},
1108-
fsClass: \\"test-class\\",
1109-
dataSentryElement: \\"Image\\",
1110-
dataSentryComponent: \\"Bananas\\",
1111-
dataSentrySourceFile: \\"filename-test.js\\"
1075+
fsClass: \\"test-class\\"
11121076
});
11131077
}
11141078
}"
11151079
`);
11161080
});
11171081

1118-
it("Bananas ignore components dataSentrySourceFile=nomatch dataSentryComponent=* dataSentryElement=nomatch snapshot matches", () => {
1119-
const result = transform(BananasStandardInput, {
1082+
it("skips components marked in ignoreComponents", () => {
1083+
const result = transform(BananasPizzaAppStandardInput, {
11201084
filename: "/filename-test.js",
1121-
configFile: false,
11221085
presets: ["@babel/preset-react"],
1123-
plugins: [[plugin, { native: true, ignoreComponents: [["nomatch.js", "*", "nomatch"]] }]],
1086+
plugins: [[plugin, { native: true, ignoreComponents: ["Bananas"] }]],
11241087
});
11251088
expect(result?.code).toMatchInlineSnapshot(`
11261089
"import React, { Component } from 'react';
1127-
import { Image } from 'react-native';
1090+
import { StyleSheet, Text, TextInput, View, Image, UIManager } from 'react-native';
1091+
UIManager.getViewManagerConfig('RCTView').NativeProps.fsClass = \\"String\\";
11281092
class Bananas extends Component {
11291093
render() {
11301094
let pic = {
@@ -1137,198 +1101,75 @@ it("Bananas ignore components dataSentrySourceFile=nomatch dataSentryComponent=*
11371101
height: 110,
11381102
marginTop: 10
11391103
},
1140-
fsClass: \\"test-class\\",
1141-
dataSentryElement: \\"Image\\",
1142-
dataSentryComponent: \\"Bananas\\",
1143-
dataSentrySourceFile: \\"filename-test.js\\"
1104+
fsClass: \\"test-class\\"
11441105
});
11451106
}
1146-
}"
1147-
`);
1148-
});
1149-
1150-
it("Bananas ignore components dataSentrySourceFile=nomatch dataSentryComponent=nomatch dataSentryElement=* snapshot matches", () => {
1151-
const result = transform(BananasStandardInput, {
1152-
filename: "/filename-test.js",
1153-
configFile: false,
1154-
presets: ["@babel/preset-react"],
1155-
plugins: [[plugin, { native: true, ignoreComponents: [["nomatch.js", "nomatch", "*"]] }]],
1156-
});
1157-
expect(result?.code).toMatchInlineSnapshot(`
1158-
"import React, { Component } from 'react';
1159-
import { Image } from 'react-native';
1160-
class Bananas extends Component {
1161-
render() {
1162-
let pic = {
1163-
uri: 'https://upload.wikimedia.org/wikipedia/commons/d/de/Bananavarieties.jpg'
1107+
}
1108+
class PizzaTranslator extends Component {
1109+
constructor(props) {
1110+
super(props);
1111+
this.state = {
1112+
text: ''
11641113
};
1165-
return /*#__PURE__*/React.createElement(Image, {
1166-
source: pic,
1167-
style: {
1168-
width: 193,
1169-
height: 110,
1170-
marginTop: 10
1171-
},
1172-
fsClass: \\"test-class\\",
1173-
dataSentryElement: \\"Image\\",
1174-
dataSentryComponent: \\"Bananas\\",
1175-
dataSentrySourceFile: \\"filename-test.js\\"
1176-
});
11771114
}
1178-
}"
1179-
`);
1180-
});
1181-
1182-
it("Bananas ignore components dataSentrySourceFile=* dataSentryComponent=* dataSentryElement=nomatch snapshot matches", () => {
1183-
const result = transform(BananasStandardInput, {
1184-
filename: "/filename-test.js",
1185-
configFile: false,
1186-
presets: ["@babel/preset-react"],
1187-
plugins: [[plugin, { native: true, ignoreComponents: [["nomatch.js", "nomatch", "nomatch"]] }]],
1188-
});
1189-
expect(result?.code).toMatchInlineSnapshot(`
1190-
"import React, { Component } from 'react';
1191-
import { Image } from 'react-native';
1192-
class Bananas extends Component {
11931115
render() {
1194-
let pic = {
1195-
uri: 'https://upload.wikimedia.org/wikipedia/commons/d/de/Bananavarieties.jpg'
1196-
};
1197-
return /*#__PURE__*/React.createElement(Image, {
1198-
source: pic,
1116+
return /*#__PURE__*/React.createElement(View, {
11991117
style: {
1200-
width: 193,
1201-
height: 110,
1202-
marginTop: 10
1118+
padding: 10
12031119
},
1204-
fsClass: \\"test-class\\",
1205-
dataSentryElement: \\"Image\\",
1206-
dataSentryComponent: \\"Bananas\\",
1120+
dataSentryElement: \\"View\\",
1121+
dataSentryComponent: \\"PizzaTranslator\\",
12071122
dataSentrySourceFile: \\"filename-test.js\\"
1208-
});
1209-
}
1210-
}"
1211-
`);
1212-
});
1213-
1214-
it("Bananas ignore components dataSentrySourceFile=* dataSentryComponent=nomatch dataSentryElement=* snapshot matches", () => {
1215-
const result = transform(BananasStandardInput, {
1216-
filename: "/filename-test.js",
1217-
configFile: false,
1218-
presets: ["@babel/preset-react"],
1219-
plugins: [[plugin, { native: true, ignoreComponents: [["nomatch.js", "nomatch", "nomatch"]] }]],
1220-
});
1221-
expect(result?.code).toMatchInlineSnapshot(`
1222-
"import React, { Component } from 'react';
1223-
import { Image } from 'react-native';
1224-
class Bananas extends Component {
1225-
render() {
1226-
let pic = {
1227-
uri: 'https://upload.wikimedia.org/wikipedia/commons/d/de/Bananavarieties.jpg'
1228-
};
1229-
return /*#__PURE__*/React.createElement(Image, {
1230-
source: pic,
1123+
}, /*#__PURE__*/React.createElement(TextInput, {
12311124
style: {
1232-
width: 193,
1233-
height: 110,
1234-
marginTop: 10
1125+
backgroundColor: '#000',
1126+
color: '#eee',
1127+
padding: 8
12351128
},
1236-
fsClass: \\"test-class\\",
1237-
dataSentryElement: \\"Image\\",
1238-
dataSentryComponent: \\"Bananas\\",
1129+
placeholder: \\"Type here to translate!\\" // not supported on iOS
1130+
,
1131+
onChangeText: text => this.setState({
1132+
text
1133+
}),
1134+
value: this.state.text,
1135+
dataSentryElement: \\"TextInput\\",
12391136
dataSentrySourceFile: \\"filename-test.js\\"
1240-
});
1241-
}
1242-
}"
1243-
`);
1244-
});
1245-
1246-
it("Bananas ignore components dataSentrySourceFile=nomatch dataSentryComponent=* dataSentryElement=* snapshot matches", () => {
1247-
const result = transform(BananasStandardInput, {
1248-
filename: "/filename-test.js",
1249-
configFile: false,
1250-
presets: ["@babel/preset-react"],
1251-
plugins: [[plugin, { native: true, ignoreComponents: [["nomatch.js", "nomatch", "nomatch"]] }]],
1252-
});
1253-
expect(result?.code).toMatchInlineSnapshot(`
1254-
"import React, { Component } from 'react';
1255-
import { Image } from 'react-native';
1256-
class Bananas extends Component {
1257-
render() {
1258-
let pic = {
1259-
uri: 'https://upload.wikimedia.org/wikipedia/commons/d/de/Bananavarieties.jpg'
1260-
};
1261-
return /*#__PURE__*/React.createElement(Image, {
1262-
source: pic,
1137+
}), /*#__PURE__*/React.createElement(Text, {
12631138
style: {
1264-
width: 193,
1265-
height: 110,
1266-
marginTop: 10
1139+
padding: 10,
1140+
fontSize: 42
12671141
},
1268-
fsClass: \\"test-class\\",
1269-
dataSentryElement: \\"Image\\",
1270-
dataSentryComponent: \\"Bananas\\",
1142+
dataSentryElement: \\"Text\\",
12711143
dataSentrySourceFile: \\"filename-test.js\\"
1272-
});
1273-
}
1274-
}"
1275-
`);
1276-
});
1277-
1278-
// This tests out matching only `dataSentryElement`, with * for the others
1279-
it("Bananas ignore components dataSentrySourceFile=* dataSentryComponent=* dataSentryElement=match snapshot matches", () => {
1280-
const result = transform(BananasStandardInput, {
1281-
filename: "/filename-test.js",
1282-
configFile: false,
1283-
presets: ["@babel/preset-react"],
1284-
plugins: [[plugin, { native: true, ignoreComponents: ["Image"] }]],
1285-
});
1286-
expect(result?.code).toMatchInlineSnapshot(`
1287-
"import React, { Component } from 'react';
1288-
import { Image } from 'react-native';
1289-
class Bananas extends Component {
1290-
render() {
1291-
let pic = {
1292-
uri: 'https://upload.wikimedia.org/wikipedia/commons/d/de/Bananavarieties.jpg'
1293-
};
1294-
return /*#__PURE__*/React.createElement(Image, {
1295-
source: pic,
1296-
style: {
1297-
width: 193,
1298-
height: 110,
1299-
marginTop: 10
1300-
},
1301-
fsClass: \\"test-class\\"
1302-
});
1144+
}, this.state.text.split(' ').map(word => word && '🍕').join(' ')));
13031145
}
1304-
}"
1305-
`);
1306-
});
1307-
1308-
it("Bananas incompatible plugin @react-navigation source snapshot matches", () => {
1309-
const result = transform(BananasStandardInput, {
1310-
filename: "test/node_modules/@react-navigation/core/filename-test.js",
1311-
presets: ["@babel/preset-react"],
1312-
plugins: [[plugin, { native: true }]],
1313-
});
1314-
expect(result?.code).toMatchInlineSnapshot(`
1315-
"import React, { Component } from 'react';
1316-
import { Image } from 'react-native';
1317-
class Bananas extends Component {
1318-
render() {
1319-
let pic = {
1320-
uri: 'https://upload.wikimedia.org/wikipedia/commons/d/de/Bananavarieties.jpg'
1321-
};
1322-
return /*#__PURE__*/React.createElement(Image, {
1323-
source: pic,
1324-
style: {
1325-
width: 193,
1326-
height: 110,
1327-
marginTop: 10
1328-
},
1329-
fsClass: \\"test-class\\"
1330-
});
1146+
}
1147+
export default function App() {
1148+
return /*#__PURE__*/React.createElement(View, {
1149+
style: styles.container,
1150+
dataSentryElement: \\"View\\",
1151+
dataSentryComponent: \\"App\\",
1152+
dataSentrySourceFile: \\"filename-test.js\\"
1153+
}, /*#__PURE__*/React.createElement(Text, {
1154+
style: {
1155+
color: '#eee'
1156+
},
1157+
dataSentryElement: \\"Text\\",
1158+
dataSentrySourceFile: \\"filename-test.js\\"
1159+
}, \\"FullStory ReactNative testing app\\"), /*#__PURE__*/React.createElement(Bananas, null), /*#__PURE__*/React.createElement(PizzaTranslator, {
1160+
dataSentryElement: \\"PizzaTranslator\\",
1161+
dataSentrySourceFile: \\"filename-test.js\\"
1162+
}));
1163+
}
1164+
const styles = StyleSheet.create({
1165+
container: {
1166+
flex: 1,
1167+
justifyContent: 'center',
1168+
alignItems: 'stretch',
1169+
backgroundColor: '#222',
1170+
alignItems: 'center',
1171+
justifyContent: 'center'
13311172
}
1332-
}"
1173+
});"
13331174
`);
13341175
});

0 commit comments

Comments
 (0)