Skip to content

Instantly share code, notes, and snippets.

Daniel Kuroski kuroski

Block or report user

Report or block kuroski

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View router.spec.js
jest.mock('@/guards');
import router from "@/router";
import { guardToken, guardCustom } from "@/guards";
describe("router", () => {
it("calls 'guardToken' before each route transition", () => {
router.push({ name: 'dashboard' });
expect(guardToken).toHaveBeenCalled();
});
View 05-VUserSearchForm.spec.js
import { shallowMount, mount, createLocalVue } from '@vue/test-utils'
import ElementUI from 'element-ui'
import VUserSearchForm from '@/components/VUserSearchForm'
const localVue = createLocalVue()
localVue.use(ElementUI)
describe('VUserSearchForm', () => {
const build = () => {
const options = { localVue }
View 04-VUserSearchForm.spec.js
...
...
it('calls "submitted" event when submitting form', () => {
// arrange
const expectedUser = 'kuroski'
const { wrapperMounted, button, inputMounted } = build()
inputMounted().element.value = expectedUser
// act
inputMounted().trigger('input')
View 03-VUserSearchForm.spec.js
import { shallowMount, mount, createLocalVue } from '@vue/test-utils'
import ElementUI from 'element-ui'
import VUserSearchForm from '@/components/VUserSearchForm'
const localVue = createLocalVue()
localVue.use(ElementUI)
describe('VUserSearchForm', () => {
const build = () => {
const options = { localVue }
View 02-VUserSearchForm.spec.js
import { shallowMount, mount, createLocalVue } from '@vue/test-utils'
import ElementUI from 'element-ui'
import VUserSearchForm from '@/components/VUserSearchForm'
const localVue = createLocalVue()
localVue.use(ElementUI)
describe('VUserSearchForm', () => {
const build = () => {
const wrapper = shallowMount(VUserSearchForm, { localVue })
View 03-VUserSearchForm.vue
<script>
export default {
name: 'UserSearchForm',
data() {
return {
username: ''
}
}
}
</script>
View router.js
import Vue from 'vue'
import Router from 'vue-router'
const UserView = () => import('@/views/UserView')
Vue.use(Router)
export default new Router({
mode: 'history',
base: process.env.BASE_URL,
routes: [
View api.js
import axios from 'axios'
import httpAdapter from 'axios/lib/adapters/http'
const instance = axios.create({
baseURL: 'https://api.github.com',
adapter: httpAdapter,
})
export default {
searchUser(username) {
View api.spec.js
import flushPromises from 'flush-promises'
import nock from 'nock'
import api from '@/api'
import userFixture from './fixtures/user'
describe('api', () => {
it('searches for the user', async () => {
// arrange
const expectedUser = 'kuroski'
View mutations.js
export default {
SET_USER(state, user) {
state.user = { ...user }
}
}
You can’t perform that action at this time.