Skip to content

Instantly share code, notes, and snippets.

@imdadul
imdadul / mocking-bug.js
Created March 21, 2019 10:06
How mocking can be dangerous sometime, missing the integration between functions.
function Person(firstName, lastName, address) {
let self = this;
this.firstName = firstName;
this.lastName = lastName;
this.address = address;
/**
* @return {string}
*/
this.getInfo = function() {
return {
@imdadul
imdadul / person-all-public.js
Last active March 21, 2019 10:08
Writing test for all functions.
/**
* @param firstName
* @param lastName
* @param address
* @constructor
*/
function Person(firstName, lastName, address) {
let self = this;
this.firstName = firstName;
this.lastName = lastName;
@imdadul
imdadul / withGlobal
Last active April 1, 2022 00:44
Writing test only for public functions.
const Parent: React.FC = () => {
return <ChildWrapper cat="mew" />
}
type ChildProps = {
cat: string
}
const Child: React.FC<ChildProps & { global: string }> = ({ cat }) => {
return <span>{cat}</span>
}