Develop #8
@@ -17,7 +17,6 @@ export default {
|
|||||||
},
|
},
|
||||||
addFruit: async ({ commit }, fruit) => {
|
addFruit: async ({ commit }, fruit) => {
|
||||||
commit("setLoading", true);
|
commit("setLoading", true);
|
||||||
console.log("here");
|
|
||||||
await axios
|
await axios
|
||||||
.post("http://localhost:3000/fruit", fruit)
|
.post("http://localhost:3000/fruit", fruit)
|
||||||
.then(res => commit("addFruit", res.data))
|
.then(res => commit("addFruit", res.data))
|
||||||
|
|||||||
@@ -1,12 +1,10 @@
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
plugins: [
|
plugins: ["cypress"],
|
||||||
'cypress',
|
|
||||||
],
|
|
||||||
env: {
|
env: {
|
||||||
mocha: true,
|
mocha: true,
|
||||||
'cypress/globals': true,
|
"cypress/globals": true
|
||||||
},
|
},
|
||||||
rules: {
|
rules: {
|
||||||
strict: 'off',
|
strict: "off"
|
||||||
},
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -17,10 +17,10 @@ module.exports = (on, config) => {
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
...config,
|
...config,
|
||||||
fixturesFolder: 'tests/e2e/fixtures',
|
fixturesFolder: "tests/e2e/fixtures",
|
||||||
integrationFolder: 'tests/e2e/specs',
|
integrationFolder: "tests/e2e/specs",
|
||||||
screenshotsFolder: 'tests/e2e/screenshots',
|
screenshotsFolder: "tests/e2e/screenshots",
|
||||||
videosFolder: 'tests/e2e/videos',
|
videosFolder: "tests/e2e/videos",
|
||||||
supportFile: 'tests/e2e/support/index.js',
|
supportFile: "tests/e2e/support/index.js"
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
// https://docs.cypress.io/api/introduction/api.html
|
// https://docs.cypress.io/api/introduction/api.html
|
||||||
|
|
||||||
describe('My First Test', () => {
|
describe("My First Test", () => {
|
||||||
it('Visits the app root url', () => {
|
it("Visits the app root url", () => {
|
||||||
cy.visit('/');
|
cy.visit("/");
|
||||||
cy.contains('h1', 'Welcome to Your Vue.js App');
|
cy.contains("h1", "Welcome to Your Vue.js App");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
// ***********************************************************
|
// ***********************************************************
|
||||||
|
|
||||||
// Import commands.js using ES2015 syntax:
|
// Import commands.js using ES2015 syntax:
|
||||||
import './commands';
|
import "./commands";
|
||||||
|
|
||||||
// Alternatively you can use CommonJS syntax:
|
// Alternatively you can use CommonJS syntax:
|
||||||
// require('./commands')
|
// require('./commands')
|
||||||
|
|||||||
@@ -10,10 +10,10 @@ describe("Test AddFruit component.", () => {
|
|||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
actions = {
|
actions = {
|
||||||
addFruit: jest.fn(),
|
addFruit: jest.fn()
|
||||||
};
|
};
|
||||||
mutations = {
|
mutations = {
|
||||||
toggleModal: jest.fn(),
|
toggleModal: jest.fn()
|
||||||
};
|
};
|
||||||
store = new Vuex.Store({ actions, mutations });
|
store = new Vuex.Store({ actions, mutations });
|
||||||
});
|
});
|
||||||
@@ -27,14 +27,14 @@ describe("Test AddFruit component.", () => {
|
|||||||
const wrapper = shallowMount(AddFruit, { store, localVue });
|
const wrapper = shallowMount(AddFruit, { store, localVue });
|
||||||
expect(wrapper.vm.$data.fruit).toEqual({
|
expect(wrapper.vm.$data.fruit).toEqual({
|
||||||
color: "#000000",
|
color: "#000000",
|
||||||
isFruit: true,
|
isFruit: true
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("closes AddFruit modal on Cancel click.", () => {
|
it("closes AddFruit modal on Cancel click.", () => {
|
||||||
const wrapper = shallowMount(AddFruit, {
|
const wrapper = shallowMount(AddFruit, {
|
||||||
store,
|
store,
|
||||||
localVue,
|
localVue
|
||||||
});
|
});
|
||||||
const cancelBtn = wrapper.find(".btn--cancel");
|
const cancelBtn = wrapper.find(".btn--cancel");
|
||||||
cancelBtn.trigger("click");
|
cancelBtn.trigger("click");
|
||||||
@@ -44,7 +44,7 @@ describe("Test AddFruit component.", () => {
|
|||||||
it("dispatches addFruit action on form submission.", () => {
|
it("dispatches addFruit action on form submission.", () => {
|
||||||
const wrapper = shallowMount(AddFruit, {
|
const wrapper = shallowMount(AddFruit, {
|
||||||
store,
|
store,
|
||||||
localVue,
|
localVue
|
||||||
});
|
});
|
||||||
const form = wrapper.find("form");
|
const form = wrapper.find("form");
|
||||||
form.trigger("submit");
|
form.trigger("submit");
|
||||||
@@ -54,7 +54,7 @@ describe("Test AddFruit component.", () => {
|
|||||||
it("checks that 'is-overlayed' class is added/removed to <body> on mounted/destroy.", () => {
|
it("checks that 'is-overlayed' class is added/removed to <body> on mounted/destroy.", () => {
|
||||||
const wrapper = shallowMount(AddFruit, {
|
const wrapper = shallowMount(AddFruit, {
|
||||||
store,
|
store,
|
||||||
localVue,
|
localVue
|
||||||
});
|
});
|
||||||
expect(document.body.classList).toContain("is-overlayed");
|
expect(document.body.classList).toContain("is-overlayed");
|
||||||
wrapper.destroy();
|
wrapper.destroy();
|
||||||
|
|||||||
Reference in New Issue
Block a user