donal
2018-04-21 d3c92cdb92e37963dfb4ec69da9c728747d671a5
FIX - linting errors for the build
23 files modified
178 ■■■■■ changed files
.eslintrc 10 ●●●●● patch | view | raw | blame | history
jest.config.js 19 ●●●● patch | view | raw | blame | history
nightwatch.config.js 22 ●●●●● patch | view | raw | blame | history
src/App.vue 1 ●●●● patch | view | raw | blame | history
src/components/AboutLabs.vue 11 ●●●● patch | view | raw | blame | history
src/components/Header.vue 2 ●●● 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 2 ●●● 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 12 ●●●●● 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 17 ●●●● 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 30 ●●●● 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 8 ●●●● 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
@@ -6,7 +6,7 @@
  src_folders: [
    "tests/e2e/specs" // Where you are storing your Nightwatch e2e tests
  ],
  // TODO - move to the package.json
  // TODO - move to the package.json
  // urlToTest: process.env.E2E_ENV ? `http://app-name-labs-${process.env.E2E_ENV}.apps.company-xyz.rht-labs.com`: "http://localhost:8080",
  output_folder: "./reports/e2e",
  selenium: {
@@ -41,10 +41,11 @@
      }
    }
  }
}
};
function padLeft (count) { // theregister.co.uk/2016/03/23/npm_left_pad_chaos/
  return count < 10 ? "0" + count: count.toString();
function padLeft(count) {
  // theregister.co.uk/2016/03/23/npm_left_pad_chaos/
  return count < 10 ? "0" + count : count.toString();
}
var FILECOUNT = 0; // global screenshot file count
@@ -55,15 +56,18 @@
 * While we"re at it, we are adding some meta-data to the filename, specifically
 * the Platform/Browser where the test was run and the test (file) name.
 */
function imgpath (browser) {
function imgpath(browser) {
  var a = browser.options.desiredCapabilities;
  var meta = [a.platform];
  meta.push(a.browserName ? a.browserName: "any");
  meta.push(a.version ? a.version: "any");
  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++) + "_";
}
module.exports.imgpath = imgpath;
module.exports.SCREENSHOT_PATH = SCREENSHOT_PATH;
module.exports.SCREENSHOT_PATH = SCREENSHOT_PATH;
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"
        }
      ]
    };
@@ -72,4 +71,4 @@
a {
  color: #a30000;
}
</style>
</style>
src/components/Header.vue
@@ -77,7 +77,7 @@
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.2); /* fallback for old browsers */
    background: rgba(0, 0, 0, 0.2); /* fallback for old browsers */
    // border-radius: 6px 6px 0 0;
  }
  time {
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
@@ -27,7 +27,7 @@
  },
  methods: {
    markCompleted() {
      this.$store.dispatch("updateTodo", {id :this.todoItem._id});
      this.$store.dispatch("updateTodo", { id: this.todoItem._id });
      console.info("INFO - Mark todo as completed ", this.todoItem.completed);
    },
    markImportant() {
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,10 +126,12 @@
  it("should call MARK_TODO_IMPORTANT", done => {
    const commit = sinon.spy();
    state.todos = todos;
    actions.updateTodo({ commit, state }, { id: 1 , important: true }).then(() => {
      // TODO - test goes here!
      done();
    });
    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,15 +3,14 @@
import * as all from "../setup.js";
describe("Header.vue", () => {
//   const Date = 15 / 12 / 1995;
//   it("has the expected html structure", () => {
//     const created = () => {}
//     const wrapper = shallow(Header, {
//       created
//     });
//     expect(wrapper.element).toMatchSnapshot();
//   });
  //   const Date = 15 / 12 / 1995;
  //   it("has the expected html structure", () => {
  //     const created = () => {}
  //     const wrapper = shallow(Header, {
  //       created
  //     });
  //     expect(wrapper.element).toMatchSnapshot();
  //   });
  it("calls the loadTodos function from actionsjs when created", () => {
    const created = jest.fn();
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({
      state: {},
      methods
    })
    }),
      (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
@@ -18,9 +18,9 @@
      important: false
    }
  ];
//   const methods = {
//     sumDoneTodoItems: jest.fn()
//   };
  //   const methods = {
  //     sumDoneTodoItems: jest.fn()
  //   };
  const actions = {
    loadTodos: jest.fn(),
    clearTodos: jest.fn()
@@ -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()
  });