Skip to content

Commit 8278b14

Browse files
RoderickXiiDanielGaran02Kelementz916anthonyHerrrobsinz
committed
fixed typos in createBoilerFunc
Co-authored-by: Daniel Garan <[email protected]> Co-authored-by: Kevin Can <[email protected]> Co-authored-by: Anthony Herrera <[email protected]> Co-authored-by: Rob Sinzieri <[email protected]> Co-authored-by: Roderick de Leon <[email protected]>"
1 parent 32c180c commit 8278b14

File tree

3 files changed

+31
-14
lines changed

3 files changed

+31
-14
lines changed

src/components/right-sidebar/CodeSnippet.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<input
2020
:checked="store.composition"
2121
@change="store.compositionToggle"
22-
type="checkbox"
22+
type="checkbox" class="compositiontoggle"
2323
>
2424
<span class="slider round"/>
2525
</label>

src/components/right-sidebar/createBoilerFuncs.ts

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,35 @@ import { useStore } from "../../store/main.js";
33
import { vtIcons } from "src/store/state/icons";
44
import { Component, RouteComponentMap } from "../../../types";
55

6-
const store = useStore(); // template
7-
const componentMap = computed(() => store.componentMap);
8-
const activeComponent = computed(() => store.activeComponent);
9-
const activeComponentObj = computed(() => store.activeComponentObj);
10-
const exportAsTypescript = computed(() => store.exportAsTypescript);
11-
const activeRoute = computed(() => store.activeRoute);
12-
6+
// const store = useStore(); // template
7+
// const componentMap = computed(() => store.componentMap);
8+
// const activeComponent = computed(() => store.activeComponent);
9+
// const activeComponentObj = computed(() => store.activeComponentObj);
10+
// const exportAsTypescript = computed(() => store.exportAsTypescript);
11+
// const activeRoute = computed(() => store.activeRoute);
12+
export function useComputedStore() {
13+
const store = useStore();
14+
const componentMap = computed(() => store.componentMap);
15+
const activeComponent = computed(() => store.activeComponent);
16+
const activeComponentObj = computed(() => store.activeComponentObj);
17+
const exportAsTypescript = computed(() => store.exportAsTypescript);
18+
const activeRoute = computed(() => store.activeRoute);
19+
20+
return {
21+
componentMap,
22+
activeComponent,
23+
activeComponentObj,
24+
exportAsTypescript,
25+
activeRoute
26+
};
27+
}
1328

1429
export const createBoilerOptions = (componentName: string, children: string[] | {
1530
[key: string]: RouteComponentMap | Component;
1631
App: RouteComponentMap;
1732
HomeView: RouteComponentMap;
1833
}) => {
34+
const { componentMap, activeComponent, exportAsTypescript, activeComponentObj } = useComputedStore();
1935
// add import mapstate and mapactions if they exist
2036
let imports = "";
2137
const activeComp = componentMap.value[activeComponent.value] as Component;
@@ -69,7 +85,7 @@ export const createBoilerOptions = (componentName: string, children: string[] |
6985

7086
const vtComponents: string[] = [];
7187

72-
htmlBinding.forEach((el) => {
88+
htmlBinding.forEach((el: {text: string}) => {
7389
if (vuetensilsSet.has(el.text)) {
7490
// Add import statement for Vuetensils components
7591
vtComponents.push(el.text);
@@ -83,7 +99,7 @@ export const createBoilerOptions = (componentName: string, children: string[] |
8399
}
84100

85101
data += " data() {\n return {\n";
86-
htmlBinding.forEach((el) => {
102+
htmlBinding.forEach((el: { binding: string }) => {
87103
if (el.binding !== "") {
88104
data += ` ${el.binding}: "PLACEHOLDER FOR VALUE", `;
89105
data += "\n";
@@ -185,6 +201,7 @@ export const createBoilerComposition = (componentName: string, children: string[
185201
App: RouteComponentMap;
186202
HomeView: RouteComponentMap;
187203
}) => {
204+
const { componentMap, activeComponent, activeComponentObj, exportAsTypescript } = useComputedStore();
188205
// add import mapstate and mapactions if they exist
189206
let imports = "";
190207
const activeComp = componentMap.value[activeComponent.value] as Component;
@@ -234,7 +251,7 @@ export const createBoilerComposition = (componentName: string, children: string[
234251

235252
const vtComponents: string[] = [];
236253

237-
htmlBinding.forEach((el) => {
254+
htmlBinding.forEach((el: { text: string }) => {
238255
if (vuetensilsSet.has(el.text)) {
239256
// Add import statement for Vuetensils components
240257
vtComponents.push(el.text);
@@ -251,7 +268,7 @@ data += " setup() {"
251268
if(activeComp.state.length || activeComp.actions.length){
252269
data += " \n const /* testStore */ = useStore(); ";
253270
}
254-
htmlBinding.forEach((el) => {
271+
htmlBinding.forEach((el: { binding: string }) => {
255272
if (el.binding !== "") {
256273
data += ` ${el.binding}: "PLACEHOLDER FOR VALUE", `;
257274
data += "\n";

test/jest/__tests__/stateChangeTest.spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@ describe('CodeSnippet', () => {
3030
const store = useStore();
3131

3232
// the initial value of store.options is false using the expect function.
33-
expect(store.options).toBe(false);
33+
expect(store.composition).toBe(false);
3434

3535
// Find the checkbox input with the class compositiontoggle in the wrapper, trigger a change event on it, and wait for any potential DOM updates using the nextTick method.
3636
await wrapper.find('input.compositiontoggle').trigger('change');
3737
await wrapper.vm.$nextTick(); //wait for any potential DOM updates
3838

3939
//the final value of store.options is true using the expect function.
40-
expect(store.options).toBe(true);
40+
expect(store.composition).toBe(true);
4141
});
4242
});

0 commit comments

Comments
 (0)