Skip to content

Instantly share code, notes, and snippets.

View hassanjuniedi's full-sized avatar

Hassan Juniedi hassanjuniedi

View GitHub Profile
@hassanjuniedi
hassanjuniedi / Home.test.js
Created November 1, 2020 22:32
#vue-test
import { mount } from "@vue/test-utils";
import Home from "../Home.vue";
describe('Home page', () => {
it('render html correctly', () => {
const wrapper = mount(Home);
expect(wrapper.html()).toMatchSnapshot();
});
it('Should change the status text to `Success` if login succeeds', async() => {
import { shallowMount } from "@vue/test-utils";
import Login from "../Login.vue";
describe('Login component', () => {
it('render html correctly', () => {
const wrapper = mount(Login);
expect(wrapper.html()).toMatchSnapshot();
});
it('Should emit `failed` if the login failed', async() => {
@hassanjuniedi
hassanjuniedi / jest.config.js
Last active November 1, 2020 22:24
jest.config.js example for Vue testing #vue-test
// jest.config.js
module.exports = {
"moduleFileExtensions": [
"js",
"json",
// tell Jest to handle `*.vue` files
"vue"
],
"transform": {
// process `*.vue` files with `vue-jest`
@hassanjuniedi
hassanjuniedi / package.json
Last active November 1, 2020 21:34
Add commands in package.json to run unit and integration tests.
"scripts": {
"test": "NODE_ENV=test TEST_CLASS=unit jest",
"integration-test": "NODE_ENV=test TEST_CLASS=integration jest"
},
@hassanjuniedi
hassanjuniedi / unwraptag-tag.directive.ts
Created May 10, 2018 15:25
Angular directive to unwrap HTML tag or unwrap component tag.
import { AfterViewInit, Directive, ElementRef } from '@angular/core';
@Directive({
selector: '[appUnwraptag]',
})
export class UnwrapTagDirective implements AfterViewInit {
constructor(private el: ElementRef) {}
ngAfterViewInit() {
// get the element's parent node
@hassanjuniedi
hassanjuniedi / wp_insert_post_externally.php
Last active November 5, 2016 11:54
Insert Wordpress post with featured image and category by HTTP POST
<?php
/*
Put this file in wordpress root directory .
POST parameters should contain :
title = for post title ,
content = for post content ,
cat_id = for category ID ,
imgUrl = for featured image URL . (url must end with .jpg , .png or .gif)