1- import reducer , { addComponent , clearProject , createComponent , deleteComponent , reorderComponent , saveComponentCode , setCurrentFile } from '../src/redux/canvasSlice' ;
1+ import reducer , { addComponent , clearProject , createComponent , reorderComponent , setCurrentFile } from '../src/redux/canvasSlice' ;
22
33describe ( 'canvasSlice reducers' , ( ) => {
44 let initialState ;
@@ -26,6 +26,32 @@ describe('canvasSlice reducers', () => {
2626 initialState = {
2727 components : [ ] ,
2828 code : '' ,
29+ cssCode : `html {
30+ box-sizing: border-box;
31+ height: 100%;
32+ }
33+ body {
34+ margin: 0;
35+ padding-top: 20%;
36+ overflow: hidden;
37+ background-color: #272727;
38+ font-family: "Helvetica Neue";
39+ display: flex;
40+ justify-content: center;
41+ text-align: center;
42+ height: 100%;
43+ }
44+ h1 {
45+ color: white;
46+ font-size: 3rem;
47+ }
48+ p {
49+ color: white;
50+ font-size: 1.5rem;
51+ }
52+ .default-spans {
53+ color: #4338ca;
54+ }` ,
2955 tags : [ ] ,
3056 customComponents : [ ] ,
3157 imports : [ "import React from 'react';\n" ] ,
@@ -57,6 +83,14 @@ describe('canvasSlice reducers', () => {
5783 fileImports : [ ] ,
5884 fileComponents : [ ] ,
5985 } ,
86+ {
87+ type : 'file' ,
88+ name : 'styles.css' ,
89+ fileCode : '' ,
90+ fileTags : [ ] ,
91+ fileImports : [ ] ,
92+ fileComponents : [ ] ,
93+ } ,
6094 ] ,
6195 currentFile : 'App.js' ,
6296 } ;
@@ -83,13 +117,6 @@ describe('canvasSlice reducers', () => {
83117 } ) ;
84118 } ) ;
85119
86- // describe('deleteComponent:', () => {
87- // test('should remove from middle of array', () => {
88- // const action = createAction(1, 'Anchor');
89- // expect(reducer(initialState, deleteComponent(action))).toEqual({...initialState, components: ['Div', 'Button']});
90- // });
91- // });
92-
93120 describe ( 'reorderComponent:' , ( ) => {
94121 test ( 'should swap 2 items' , ( ) => {
95122 const action = createAction ( 1 , 'Button' , 2 ) ;
@@ -131,6 +158,14 @@ describe('canvasSlice reducers', () => {
131158 fileImports : [ ] ,
132159 fileComponents : [ ] ,
133160 } ,
161+ {
162+ type : 'file' ,
163+ name : 'styles.css' ,
164+ fileCode : '' ,
165+ fileTags : [ ] ,
166+ fileImports : [ ] ,
167+ fileComponents : [ ] ,
168+ } ,
134169 {
135170 type : 'file' ,
136171 name : 'TestFile.jsx' ,
@@ -150,23 +185,4 @@ describe('canvasSlice reducers', () => {
150185 expect ( reducer ( initialState , setCurrentFile ( 'TestFile.jsx' ) ) ) . toEqual ( { ...initialState , currentFile : 'TestFile.jsx' } ) ;
151186 } ) ;
152187 } ) ;
153-
154- // describe('saveComponentCode:', () => {
155- // test('should save state into files', () => {
156- // initialState.files.push({
157- // type: 'file',
158- // name: 'TestFile.jsx',
159- // fileCode: `import React from 'react';\n\nconst TestFile = () => {\n\treturn (\n\t\t<div>\n\t\t</div>\n\t)\n}\nexport default TestFile;`,
160- // fileTags: [],
161- // fileImports: ["import React from 'react';\n"],
162- // fileComponents: [],
163- // });
164-
165- // initialState.currentFile = 'TestFile.jsx';
166-
167- // const newState = {...initialState, code: 'test'}
168-
169- // expect(reducer(initialState, saveComponentCode())).toEqual({newState});
170- // });
171- // });
172188} ) ;
0 commit comments