Skip to content

Instantly share code, notes, and snippets.

View yashikagarg13's full-sized avatar

Yashika Garg yashikagarg13

View GitHub Profile
@yashikagarg13
yashikagarg13 / PageForm.js
Created June 2, 2018 11:18
Simple react component for writing test using Jest and Enzyme
import React from "react";
export const Form = ({name, age, onSubmit, onUpdate}) => {
return (
<form onSubmit={onSubmit}>
<div className="form-group">
<label className="control-label">Name</label>
<div className="controls">
<input
type="text"
import {add} from "helpers"
const calculator = (a, b, op) => {
if (op == "+")
return add (a, b);
}
/********************************************************************
When we unit test calculator, we are concerned with whether
calculator calls add helper or not if `op` is `+` and not with
import {add} from "helpers"
const calculator = (a, b, op) => {
if (op == "+")
return add (a, b);
}
/********************************************************************
When we unit test calculator, we are concerned with whether
calculator calls add helper or not if `op` is `+` and not with
import {add} from "helpers"
const calculator = (a, b, op) => {
if (op == "+")
return add (a, b);
}
/********************************************************************
When we unit test calculator, we are concerned with whether
calculator calls add helper or not if `op` is `+` and not with
@yashikagarg13
yashikagarg13 / Form.js
Last active May 6, 2017 06:26
Jest Blog
class Form extends React.Component {
constructor(props) {
super(props);
this.state = {
input: "",
};
this.onChangeHandler = this.onChangeHandler.bind(this);
this.onSubmitHandler = this.onSubmitHandler.bind(this);
}
@yashikagarg13
yashikagarg13 / Person.js
Last active May 6, 2017 06:26
Jest Blog
// Person class
class Person {
sayHello (name) {
console.log("Hello" + name + "!");
}
}
// Person class test cases
// - it should print "Hello JS!” if sayHello is called with “JS” ================> PASSED
// - it should print “Hello World!” if sayHello is called with no parameters.====> FAILED
/************************************************************************
Helper Method name: transformToEvents.
Input: "talent-job-associations" object
{
type: "associations",
job: {...}, // Job Object
talentId: "1",
associations: [{
status: "Interested",
/************************************************************************
Helper Method name: transformToEvents.
Input: talent-job-associations object
{
type: "associations",
job: {...}, // Job Object
talentId: "1",
associations: [{
status: "Interested",
@yashikagarg13
yashikagarg13 / index.html
Last active March 20, 2017 12:42 — forked from anonymous/index.html
ToDo App - Separate Action creators. source https://jsbin.com/nexumip
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
<script src="https://unpkg.com/react@15/dist/react.js"></script>
<script src="https://unpkg.com/react-dom@15/dist/react-dom.js"></script>
<script src="https://wzrd.in/standalone/deep-freeze@latest"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/redux/3.6.0/redux.js"></script>
@yashikagarg13
yashikagarg13 / index.html
Last active March 20, 2017 12:34 — forked from anonymous/index.html
TODO App - Passing store as context using ReactRedux's Provider and creating container components using connect method source https://jsbin.com/nexumip
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
<script src="https://unpkg.com/react@15/dist/react.js"></script>
<script src="https://unpkg.com/react-dom@15/dist/react-dom.js"></script>
<script src="https://wzrd.in/standalone/deep-freeze@latest"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/redux/3.6.0/redux.js"></script>