donal
2018-04-21 d3c92cdb92e37963dfb4ec69da9c728747d671a5
FIX - linting errors for the build
23 files modified
124 ■■■■■ changed files
.eslintrc 8 ●●●●● patch | view | raw | blame | history
jest.config.js 19 ●●●● patch | view | raw | blame | history
nightwatch.config.js 10 ●●●● patch | view | raw | blame | history
src/App.vue 1 ●●●● patch | view | raw | blame | history
src/components/AboutLabs.vue 9 ●●●●● patch | view | raw | blame | history
src/components/Header.vue patch | view | raw | blame | history
src/components/ListOfTodos.vue 1 ●●●● patch | view | raw | blame | history
src/components/NewTodo.vue 1 ●●●● patch | view | raw | blame | history
src/components/TodoItem.vue patch | view | raw | blame | history
src/config/dev.js 3 ●●●● patch | view | raw | blame | history
src/config/test.js 3 ●●●● patch | view | raw | blame | history
src/store/mutations.js 2 ●●● patch | view | raw | blame | history
src/views/ComponentView.vue 4 ●●● patch | view | raw | blame | history
src/views/Home.vue 1 ●●●● patch | view | raw | blame | history
src/views/Todo.vue 10 ●●●●● patch | view | raw | blame | history
tests/unit/javascript/actions.spec.js 4 ●●● patch | view | raw | blame | history
tests/unit/javascript/mutations.spec.js 2 ●●●●● patch | view | raw | blame | history
tests/unit/setup.js 4 ●●●● patch | view | raw | blame | history
tests/unit/vue-components/Header.spec.js 1 ●●●● patch | view | raw | blame | history
tests/unit/vue-components/ListOfTodos.spec.js 12 ●●●● patch | view | raw | blame | history
tests/unit/vue-components/NewTodo.spec.js 26 ●●●● patch | view | raw | blame | history
tests/unit/vue-components/Todo.spec.js 1 ●●●● patch | view | raw | blame | history
tests/unit/vue-components/XofYItems.spec.js 2 ●●● patch | view | raw | blame | history
.eslintrc
@@ -1,14 +1,12 @@
{
  "root": true,
  "extends": [
    "plugin:vue/essential",
    "@vue/prettier"
  ],
  "extends": ["plugin:vue/essential", "@vue/prettier"],
  "env": {
    "es6": true,
    "node": true
  },
  "ecmaFeatures": {
    "modules": true
  }
  },
  "rules": { "no-unused-vars": 0 }
}
jest.config.js
@@ -1,10 +1,5 @@
module.exports = {
  moduleFileExtensions: [
    "js",
    "jsx",
    "json",
    "vue"
  ],
  moduleFileExtensions: ["js", "jsx", "json", "vue"],
  transform: {
    "^.+\\.vue$": "vue-jest",
    "^.+\\.jsx?$": "babel-jest"
@@ -19,11 +14,7 @@
    "!src/**/*.test.{js,jsx}",
    "!<rootDir>/node_modules/"
  ],
  testResultsProcessor: './node_modules/jest-junit-reporter',
  coverageDirectory: './reports/coverage',
  coverageReporters: [
    "text",
    "html",
    "clover"
  ]
}
  testResultsProcessor: "./node_modules/jest-junit-reporter",
  coverageDirectory: "./reports/coverage",
  coverageReporters: ["text", "html", "clover"]
};
nightwatch.config.js
@@ -41,9 +41,10 @@
      }
    }
  }
}
};
function padLeft (count) { // theregister.co.uk/2016/03/23/npm_left_pad_chaos/
function padLeft(count) {
  // theregister.co.uk/2016/03/23/npm_left_pad_chaos/
  return count < 10 ? "0" + count: count.toString();
}
@@ -61,7 +62,10 @@
  meta.push(a.browserName ? a.browserName: "any");
  meta.push(a.version ? a.version: "any");
  meta.push(a.name); // this is the test filename so always exists.
  var metadata = meta.join("~").toLowerCase().replace(/ /g, "");
  var metadata = meta
    .join("~")
    .toLowerCase()
    .replace(/ /g, "");
  return SCREENSHOT_PATH + metadata + "_" + padLeft(FILECOUNT++) + "_";
}
src/App.vue
@@ -10,7 +10,6 @@
</template>
<style lang="scss">
@import "scss/custom.scss";
#app {
src/components/AboutLabs.vue
@@ -35,19 +35,18 @@
        },
        {
          name: "Inside a Residency Blog",
          url: "https://developers.redhat.com/blog/2018/01/26/part-1-inside-open-innovation-labs-residency/"
          url:
            "https://developers.redhat.com/blog/2018/01/26/part-1-inside-open-innovation-labs-residency/"
        }
      ],
      social: [
        {
          name: "YouTube",
          url:
            "https://www.youtube.com/watch?v=RxOKoqpDuIA"
          url: "https://www.youtube.com/watch?v=RxOKoqpDuIA"
        },
        {
          name: "Twitter",
          url:
            "https://twitter.com/redhatlabs?lang=en"
          url: "https://twitter.com/redhatlabs?lang=en"
        }
      ]
    };
src/components/Header.vue
src/components/ListOfTodos.vue
@@ -33,5 +33,4 @@
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped lang="scss">
</style>
src/components/NewTodo.vue
@@ -33,5 +33,4 @@
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped lang="scss">
</style>
src/components/TodoItem.vue
src/config/dev.js
@@ -1,3 +1,4 @@
export default {
  todoEndpoint: "http://todolist-api-<YOUR_NAME>-dev.apps.somedomain.com/api/todos"
  todoEndpoint:
    "http://todolist-api-<YOUR_NAME>-dev.apps.somedomain.com/api/todos"
};
src/config/test.js
@@ -1,3 +1,4 @@
export default {
  todoEndpoint: "http://todolist-api-<YOUR_NAME>-test.apps.somedomain.com/api/todos"
  todoEndpoint:
    "http://todolist-api-<YOUR_NAME>-test.apps.somedomain.com/api/todos"
};
src/store/mutations.js
@@ -30,5 +30,5 @@
  MARK_TODO_COMPLETED(state, index) {
    console.log("INFO - MARK_TODO_COMPLETED");
    state.todos[index].completed = !state.todos[index].completed;
  },
  }
};
src/views/ComponentView.vue
@@ -10,9 +10,7 @@
export default {
  name: "ComponentView",
  data() {
    return {
    }
    return {};
  }
};
</script>
src/views/Home.vue
@@ -25,4 +25,3 @@
  padding-top: 20px;
}
</style>
src/views/Todo.vue
@@ -26,7 +26,7 @@
import NewTodo from "@/components/NewTodo.vue";
import ListOfTodos from "@/components/ListOfTodos.vue";
import XofYItems from "@/components/XofYItems.vue";
import { mapMutations } from 'vuex'
import { mapMutations } from "vuex";
export default {
  name: "Todo",
@@ -37,12 +37,8 @@
    XofYItems
  },
  methods: {
    ...mapMutations([
      'editTodo',
      'toggleTodo',
      'deleteTodo'
    ]),
  },
    ...mapMutations(["editTodo", "toggleTodo", "deleteTodo"])
  }
};
</script>
tests/unit/javascript/actions.spec.js
@@ -126,7 +126,9 @@
  it("should call MARK_TODO_IMPORTANT", done => {
    const commit = sinon.spy();
    state.todos = todos;
    actions.updateTodo({ commit, state }, { id: 1 , important: true }).then(() => {
    actions
      .updateTodo({ commit, state }, { id: 1, important: true })
      .then(() => {
      // TODO - test goes here!
      
      done();
tests/unit/javascript/mutations.spec.js
@@ -91,12 +91,10 @@
  it("it should MARK_TODO_IMPORTANT as false", () => {
    state.todos = importantTodos;
    // TODO - test goes here!
  });
  it("it should MARK_TODO_IMPORTANT as true", () => {
    state.todos = importantTodos;
    // TODO - test goes here!
  });
});
tests/unit/setup.js
@@ -1,6 +1,6 @@
import Vue from 'vue'
import Vue from "vue";
Vue.config.productionTip = false
Vue.config.productionTip = false;
import VueMaterial from "vue-material";
// import "vue-material/dist/vue-material.min.css";
Vue.use(VueMaterial);
tests/unit/vue-components/Header.spec.js
@@ -3,7 +3,6 @@
import * as all from "../setup.js";
describe("Header.vue", () => {
//   const Date = 15 / 12 / 1995;
//   it("has the expected html structure", () => {
//     const created = () => {}
tests/unit/vue-components/ListOfTodos.spec.js
@@ -20,28 +20,28 @@
  ];
  const actions = {
    loadTodos: jest.fn()
  }
  };
  const getters = {
    todos: jest.fn()
  }
  };
  beforeEach(() => {
    store = new Vuex.Store({
      state: {},
      propsData: { todos },
      actions, getters
      actions,
      getters
    });
  });
  it("calls the loadTodos function from actionsjs when created", () => {
    const wrapper = shallow(ListOfTodos, { store, localVue });
    expect(actions.loadTodos).toHaveBeenCalled();
  })
  });
  it("maps getters with todos when computed", () => {
    const wrapper = shallow(ListOfTodos, { store, localVue });
    expect(getters.todos).toHaveBeenCalled();
  })
  });
  it("has the expected html structure", () => {
    const wrapper = shallow(ListOfTodos, { store, localVue });
tests/unit/vue-components/NewTodo.spec.js
@@ -1,42 +1,42 @@
import { shallow, createLocalVue, mount } from "@vue/test-utils";
import Vuex from 'vuex';
import Vuex from "vuex";
import NewTodo from "@/components/NewTodo.vue";
// import { expect } from 'chai'
import * as all from "../setup.js";
const localVue = createLocalVue()
const localVue = createLocalVue();
localVue.use(Vuex)
localVue.use(Vuex);
describe("NewTodo.vue", () => {
  let methods;
  let store;
  beforeEach(() => {
    methods = {
    (methods = {
      newTodoAdded: jest.fn()
    },
    store = new Vuex.Store({
    }),
      (store = new Vuex.Store({
      state: {},
      methods
    })
      }));
  });
  it("calls newTodoAdded() when keyup.enter hit.", () => {
    // time to try and test some vuex stuff and see if the methods are called when expected.
    const wrapper = shallow(NewTodo, { methods , localVue})
    const wrapper = shallow(NewTodo, { methods, localVue });
    const input = wrapper.find(".md-input");
    input.trigger('keyup.enter')
    expect(methods.newTodoAdded).toHaveBeenCalled()
    input.trigger("keyup.enter");
    expect(methods.newTodoAdded).toHaveBeenCalled();
  });
  it("does not call newTodoAdded() when keyup.space hit.", () => {
    // time to try and test some vuex stuff and see if the methods are called when expected.
    const wrapper = shallow(NewTodo, { methods , localVue})
    const wrapper = shallow(NewTodo, { methods, localVue });
    const input = wrapper.find(".md-input");
    input.trigger('keyup.space')
    expect(methods.newTodoAdded).not.toHaveBeenCalled()
    input.trigger("keyup.space");
    expect(methods.newTodoAdded).not.toHaveBeenCalled();
  });
  it("renders props.placeholderMsg when passed", () => {
tests/unit/vue-components/Todo.spec.js
@@ -18,5 +18,4 @@
    expect(wrapper.find(XofYItems)).toBeTruthy();
  });
  // NEW TEST GOES HERE
});
tests/unit/vue-components/XofYItems.spec.js
@@ -56,7 +56,7 @@
      }
    ];
    expect(mockedTodos.length).toEqual(3)
    expect(mockedTodos.length).toEqual(3);
    // Replace with testing the sumDoneTodoItems function and check it it's called
    // expect(sumDoneTodoItems).toHaveBeenCalled()
  });