Skip to content

Commit dded573

Browse files
committed
Merge branch 'stretch' of https://github.com/oslabs-beta/ReacType into testing
2 parents 8f66423 + 3cdb206 commit dded573

File tree

7 files changed

+50
-46
lines changed

7 files changed

+50
-46
lines changed

src/components/__tests__/App.test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ describe('Test the App Component', () => {
77
// wrapped version of react component
88
// component comes with additional functionality
99
const wrapped: any = shallow(<App />);
10+
1011
it('Matches snapshot', () => {
1112
// look inside wrapped component and find every instance of commentBox inside of it
1213
// expect(wrapped.find(KonvaStage).length).toEqual(1);
@@ -15,7 +16,6 @@ describe('Test the App Component', () => {
1516
it('Should contain the App Container', () => {
1617
// look inside wrapped component and find every instance of commentBox inside of it
1718
// expect(wrapped.find(KonvaStage).length).toEqual(1);
18-
expect(wrapped.contains(<AppContainer />)).toBe(true)
19-
19+
expect(wrapped.contains(<AppContainer />)).toBe(true);
2020
});
2121
});

src/components/bottom/CodePreview.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,8 @@ type CodePreviewProps = {
1717
toggleCodeEdit(): void;
1818
codeReadOnly: boolean;
1919
};
20-
20+
// comment out delete
2121
class CodePreview extends Component<CodePreviewProps> {
22-
2322
//checking if the code has been asigned yet or not
2423
//if no then generate code and asign to a focus component
2524
componentDidMount() {
@@ -44,7 +43,7 @@ class CodePreview extends Component<CodePreviewProps> {
4443
parser: 'babel'
4544
}
4645
);
47-
// console.log('code prev>>>>>>>>>>>>>>>>>>>', text);
46+
4847
this.props.updateCode({
4948
componentId: this.props.focusComponent.id,
5049
code: text

src/reducers/__tests__/leftReducers.test.ts

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -88,22 +88,24 @@ describe('Left reducers', () => {
8888
expect(newState.imageSource).toEqual(action.payload.imageSource);
8989
});
9090
});
91+
9192
// TEST DELETE CHILD: test child should be deleted from local state components array
9293
// describe('deleteChild reducer', () => {
9394
// it('should delete test component', () => {
94-
// // const action = {
95-
// // type: types.CHANGE_IMAGE_SOURCE,
96-
// // payload: { imageSource: 'www.test.com/test.img' }
97-
// // };
98-
// const model = {
99-
// parentId = state.focusComponent.id,
100-
// childId = state.focusChild.childId,
101-
// calledFromDeleteComponent = false
102-
// };
103-
// const newState = reducers.deleteChild();
95+
// // CHANGE FOCUS COMPONENT FIRST
96+
// // const action = {
97+
// // type: types.CHANGE_FOCUS_COMPONENT,
98+
// // payload: { title: 'TEST' }
99+
// // };
100+
// // const newState = reducers.changeFocusComponent(state, action.payload);
101+
// const prevState = cloneDeep(state);
102+
// console.log('this is prevState', prevState)
103+
// const newState = reducers.deleteChild(state, {});
104104
// // expecting new payload of "title" to the payload we just created
105-
// expect(newState.imageSource).toEqual(action.payload.imageSource);
105+
// expect(prevState.focusComponent.childrenArray).not.toEqual(
106+
// newState.focusComponent.childrenArray
107+
// );
106108
// });
107-
// });
108-
// NEXT TEST
109109
});
110+
111+
// NEXT TEST

src/reducers/initialState.ts

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,27 @@ export const appComponent: ComponentInt = {
2828
changed: false
2929
};
3030

31+
export const testComponent: ComponentInt = {
32+
id: 19,
33+
stateful: false,
34+
classBased: false,
35+
title: 'TEST',
36+
color: '#FF6D00',
37+
props: [],
38+
nextPropId: 1,
39+
position: {
40+
x: 25,
41+
y: 25,
42+
width: 1200,
43+
height: 800
44+
},
45+
childrenArray: [],
46+
nextChildId: 1,
47+
focusChildId: 0,
48+
code: '',
49+
changed: false
50+
};
51+
3152
const initialApplicationFocusChild: ChildInt = {
3253
childId: 0,
3354
componentName: null,
@@ -101,25 +122,3 @@ export const nativeComponentTypes = [
101122
'RNTextInput',
102123
'RNTouchOpacity'
103124
];
104-
105-
// used for reducer testing
106-
export const testComponent: ComponentInt = {
107-
id: 19,
108-
stateful: false,
109-
classBased: false,
110-
title: 'TEST',
111-
color: '#FF6D00',
112-
props: [],
113-
nextPropId: 1,
114-
position: {
115-
x: 25,
116-
y: 25,
117-
width: 1200,
118-
height: 800
119-
},
120-
childrenArray: [],
121-
nextChildId: 1,
122-
focusChildId: 0,
123-
code: '',
124-
changed: false
125-
};

src/reducers/leftReducers.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export const addChild = (
3535
// if childType is NOT included in the array of NATIVE React types && also not coming from left panel then the childType will revert to HTML
3636
!nativeComponentTypes.includes(childType) && childType !== 'COMP'
3737
? (childType = 'HTML')
38-
: childType = childType === 'COMP' ? 'COMP' : 'NATIVE';
38+
: (childType = childType === 'COMP' ? 'COMP' : 'NATIVE');
3939

4040
// view represents the curretn FOCUSED COMPONENT - this is the component where the child is being added to
4141
// we only add childrent (or do any action) to the focused omconent
@@ -302,6 +302,7 @@ export const deleteChild = (
302302
however when deleting component we wnt to delete ALL the places where it's used, so we call this function
303303
Also when calling from DELETE components , we do not touch focusComponent.
304304
************************************************************************************ */
305+
305306
if (!parentId) {
306307
window.alert('Cannot delete root child of a component');
307308
return state;
@@ -314,7 +315,7 @@ export const deleteChild = (
314315
window.alert('Cannot delete root child of a component');
315316
return state;
316317
}
317-
// make a DEEP copy of the parent component (the one thats about to loose a child)
318+
// make a DEEP copy of the parent component (the one thats about to lose a child)
318319
const parentComponentCopy: any = cloneDeep(
319320
state.components.find((comp: ComponentInt) => comp.id === parentId)
320321
);

src/utils/componentRender.util.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,10 @@ const componentRender = (
162162
return `import {${importNativeNameGenerator(
163163
child
164164
)}} from 'react-native'`;
165-
} else
166-
`import ${child.componentName} from './${child.componentName}.tsx'`;
165+
}
166+
if (child.childType === 'COMP') {
167+
return `import ${child.componentName} from './${child.componentName}.tsx'`;
168+
}
167169
})
168170
.reduce((acc: Array<string>, child) => {
169171
if (!acc.includes(child)) {

src/utils/createApplication.util.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,8 @@ export const createPackage = (path, appName) => {
8787
"express": "^4.16.4",
8888
"react": "^16.8.6",
8989
"react-dom": "^16.8.6",
90-
"webpack": "^4.29.6"
90+
"webpack": "^4.29.6",
91+
"react-native": "^0.62.1",
9192
},
9293
"devDependencies": {
9394
"@babel/core": "^7.4.3",
@@ -284,7 +285,7 @@ app.listen(8080, () => {
284285
async function createApplicationUtil({
285286
path,
286287
appName,
287-
genOption,
288+
genOption
288289
}: {
289290
path: string;
290291
appName: string;

0 commit comments

Comments
 (0)