Skip to content

Instantly share code, notes, and snippets.

@harrybeckwith
harrybeckwith / manifest.json
Created March 12, 2020 15:27
manifest.json file for chrome extensions
{
"manifest_version": 2,
"name": "extension name",
"description": "extension description",
"version": "2.0",
"content_scripts": [
{
"matches": ["<all_urls>"],
@harrybeckwith
harrybeckwith / modal.spec.js
Created November 8, 2019 15:29
unit test file using vuex
import Vuex from "vuex";
import { createLocalVue, shallowMount } from "@vue/test-utils";
import chai, { expect } from "chai";
import sinon from "sinon";
import sinonChai from "sinon-chai";
import Modal from "@/ui/Modal";
import BaseButton from "@/ui/BaseButton";
chai.use(sinonChai);
@harrybeckwith
harrybeckwith / Modal.spec.js
Created November 8, 2019 14:44
Testing a component that has vuex
import Vuex from "vuex";
import { createLocalVue, shallowMount } from "@vue/test-utils";
import chai, { expect } from "chai";
import sinon from "sinon";
import sinonChai from "sinon-chai";
import Modal from "@/ui/Modal";
import BaseButton from "@/ui/BaseButton";
chai.use(sinonChai);
@harrybeckwith
harrybeckwith / AppLoadingScreen.spec.js
Last active November 8, 2019 11:22
A basic unit test file
import Spinner from "@/ui/Spinner";
import AppLoadingScreen from "./AppLoadingScreen";
import { shallowMount } from "@vue/test-utils";
import { expect } from "chai";
describe("AppLoadingScreen", () => {
let component;
beforeEach(() => {
component = shallowMount(AppLoadingScreen);
@harrybeckwith
harrybeckwith / terminal
Created November 8, 2019 11:13
Run unit test
npm run test:unit
@harrybeckwith
harrybeckwith / package.json
Created November 8, 2019 11:12
unit test file path
"scripts": {
"test:unit": "vue-cli-service test:unit src/**/*.spec.js"
},
@harrybeckwith
harrybeckwith / app.vue
Last active August 2, 2019 09:16
data and methods for active toggle
<script>
export default {
data() {
return {
activeItem: null,
};
},
methods: {
selectItem(i) {
this.activeItem = i;
@harrybeckwith
harrybeckwith / app.vue
Created August 2, 2019 09:13
v-for vue template
<template>
<div>
<div
v-for="(item, i ) in items"
:key="i"
:class="{ active: i === activeItem}"
>
// some looped items from data here
// button for active toggle
<button @click="selectItem(i)"> make item active </button>
@harrybeckwith
harrybeckwith / store.js
Created July 24, 2019 12:19
mutations and actions
import Vue from 'vue';
import Vuex from 'vuex';
Vue.use(Vuex);
export const store = new Vuex.Store({
state: {
categories: ['travel', 'fun', 'social', 'work', 'other'],
events: [],
},
getters: {
@harrybeckwith
harrybeckwith / component.vue
Last active July 23, 2019 09:23
mapGetters and mapState
<template>
<div>
<h1>Create Event {{ userName }}</h1>
<p>There are {{catLength}} categories</p>
<ul>
<li v-for="cat in categories" :key="cat">
{{cat}}
</li>
</ul>
<p>