Skip to content

Commit c08d0f5

Browse files
Merge pull request #14 from oslabs-beta/terry/faraz/edits
Terry/Faraz/edits branch
2 parents 5faf85c + 92ca1ec commit c08d0f5

File tree

3 files changed

+34
-27
lines changed

3 files changed

+34
-27
lines changed

src/App.vue

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,14 @@ let redoMixin = {
4040
// console.log("Are these equal to each other?", action == this.undoneAction[this.undoneAction.length-1])
4141
if (!this.isTimetraveling) {
4242
if (this.undoneAction[this.undoneAction.length - 1]) {
43-
if (action.type === this.undoneAction[this.undoneAction.length - 1].type &&
44-
deepEqual(action.payload, this.undoneAction[this.undoneAction.length - 1].payload)) {
43+
if (
44+
action.type ===
45+
this.undoneAction[this.undoneAction.length - 1].type &&
46+
deepEqual(
47+
action.payload,
48+
this.undoneAction[this.undoneAction.length - 1].payload
49+
)
50+
) {
4551
this.undoneAction.pop()
4652
} else {
4753
this.undoneAction = []
@@ -50,17 +56,19 @@ let redoMixin = {
5056
}
5157
})
5258
},
53-
59+
// undo + redo function calling
60+
// metaKey accounts for Command Key on Mac
5461
mounted () {
5562
const throttledUndo = throttle(this.undo, 300)
5663
const throttledRedo = throttle(this.redo, 300)
57-
64+
// undo function calling
5865
window.addEventListener('keydown', event => {
5966
if ((event.ctrlKey || event.metaKey) && event.key === 'z') {
6067
event.preventDefault()
6168
throttledUndo()
6269
}
6370
})
71+
// redo function calling
6472
window.addEventListener('keydown', event => {
6573
if ((event.ctrlKey || event.metaKey) && event.key === 'y') {
6674
event.preventDefault()
@@ -90,8 +98,10 @@ let redoMixin = {
9098
this.undoneAction.push(undone)
9199
if (ignoredActions.has(undone.type)) {
92100
// console.log('We undid an ignored action!')
93-
while (this.doneAction[this.doneAction.length - 1] &&
94-
ignoredActions.has(this.doneAction[this.doneAction.length - 1].type)) {
101+
while (
102+
this.doneAction[this.doneAction.length - 1] &&
103+
ignoredActions.has(this.doneAction[this.doneAction.length - 1].type)
104+
) {
95105
this.undoneAction.push(this.doneAction.pop())
96106
}
97107
/* if we get here, that means we have undone all "useless" actions
@@ -130,7 +140,6 @@ let redoMixin = {
130140
this.redo()
131141
}
132142
}
133-
134143
}
135144
}
136145
@@ -140,5 +149,4 @@ export default {
140149
}
141150
</script>
142151

143-
<style>
144-
</style>
152+
<style></style>

src/components/ComponentDisplay.vue

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -382,10 +382,9 @@ export default {
382382
},
383383
watch: {
384384
activeComponent: function () {
385-
if (this.activeComponent){
385+
if (this.activeComponent) {
386386
this.onActivated(this.activeComponentObj)
387-
}
388-
else{
387+
} else {
389388
this.onDeactivated()
390389
}
391390
}

test/jest/__tests__/App.spec.js

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,18 @@ describe("Test mutations + actions to remove action from component and userActio
2525
};
2626
});
2727

28-
xit("deleting user action from state.userActions", () => {
28+
it("deleting user action from state.userActions", () => {
2929
mutations.DELETE_USER_ACTIONS(state, "action");
3030
expect(state.userActions.length).toBe(0);
3131
});
3232

33-
xit('deleting "action" from componentMap', () => {
33+
it('deleting "action" from componentMap', () => {
3434
mutations.REMOVE_ACTION_FROM_COMPONENT(state, "action");
3535
expect(state.componentMap.component.mapActions.length).toBe(0);
3636
});
3737
});
3838

39-
xdescribe("Adding actions and state to components", () => {
39+
describe("Adding actions and state to components", () => {
4040
let state;
4141
beforeEach(() => {
4242
state = {
@@ -52,15 +52,15 @@ xdescribe("Adding actions and state to components", () => {
5252
activeComponent: "testComponent"
5353
};
5454
});
55-
xdescribe("Adding actions to components", () => {
55+
describe("Adding actions to components", () => {
5656
it("should add a single action to active component", () => {
5757
mutations.ADD_TO_COMPONENT_ACTIONS(state, "testAction");
5858
expect(
5959
state.componentMap[state.activeComponent].componentActions
6060
).toEqual(["testAction"]);
6161
});
6262
});
63-
xdescribe("Adding state to components", () => {
63+
describe("Adding state to components", () => {
6464
it("should add a single state string to active component", () => {
6565
mutations.ADD_TO_COMPONENT_STATE(state, "testState");
6666
expect(state.componentMap[state.activeComponent].componentState).toEqual([
@@ -70,7 +70,7 @@ xdescribe("Adding actions and state to components", () => {
7070
});
7171
});
7272

73-
xdescribe("userActions mutation", () => {
73+
describe("userActions mutation", () => {
7474
let actions;
7575
let store;
7676
beforeEach(() => {
@@ -88,31 +88,31 @@ xdescribe("userActions mutation", () => {
8888
});
8989
});
9090

91-
xdescribe("userStore mutation", () => {
91+
describe("userStore mutation", () => {
9292
let actions;
9393
let store;
9494
store = {
9595
userStore: {}
9696
};
97-
xit("should be able to update store with a key defined by the user and a value of type object", () => {
97+
it("should be able to update store with a key defined by the user and a value of type object", () => {
9898
mutations.ADD_TO_USER_STORE(store, { dummyKey: {} });
9999
// console.log('store.userStore.dummyKey', store.userStore.dummyKey);
100100
expect(store.userStore.dummyKey).toStrictEqual({});
101101
});
102-
xit("should update user store with a key value pair with value strictly equal to empty array", () => {
102+
it("should update user store with a key value pair with value strictly equal to empty array", () => {
103103
mutations.ADD_TO_USER_STORE(store, { dummyKey: [] });
104104
expect(store.userStore.dummyKey).toStrictEqual([]);
105105
});
106-
xit("should be able to store booleans in the store as the key", () => {
106+
it("should be able to store booleans in the store as the key", () => {
107107
mutations.ADD_TO_USER_STORE(store, { boolean: true });
108108
expect(store.userStore.boolean).toBe(true);
109109
});
110-
xit("should add to userStore a key with a value of type number", () => {
110+
it("should add to userStore a key with a value of type number", () => {
111111
mutations.ADD_TO_USER_STORE(store, { number: 696 });
112112
expect(store.userStore.number).toBe(696);
113113
});
114114

115-
xit("should work with strings too", () => {
115+
it("should work with strings too", () => {
116116
mutations.ADD_TO_USER_STORE(store, { string: "string" });
117117
expect(store.userStore.string).toBe("string");
118118
});
@@ -126,7 +126,7 @@ xdescribe("userStore mutation", () => {
126126
* `userStore` holds the user defined state objects
127127
*/
128128

129-
xdescribe("Delete state in userStore/componentMap", () => {
129+
describe("Delete state in userStore/componentMap", () => {
130130
let state;
131131
beforeEach(() => {
132132
state = {
@@ -143,13 +143,13 @@ xdescribe("Delete state in userStore/componentMap", () => {
143143
userStore: { state1: true, state2: [] }
144144
};
145145
});
146-
xdescribe('"DELETE_USER_STATE" should delete property from "userStore" object', () => {
146+
describe('"DELETE_USER_STATE" should delete property from "userStore" object', () => {
147147
it("should delete a single state property", () => {
148148
mutations.DELETE_USER_STATE(state, "state1");
149149
expect(state.userStore).toEqual({ state2: [] });
150150
});
151151
});
152-
xdescribe('"REMOVE_STATE_FROM_COMPONENT" should delete state in "activeComponent"', () => {
152+
describe('"REMOVE_STATE_FROM_COMPONENT" should delete state in "activeComponent"', () => {
153153
it("should remove state from active component", () => {
154154
mutations.REMOVE_STATE_FROM_COMPONENT(state, "state2");
155155
expect(state.componentMap.test.componentState).toEqual(["state1"]);

0 commit comments

Comments
 (0)