Photo by Christina @ wocintechchat.com on Unsplash
  1. Three things
  • Test suites (describe block)

2. Rendering methods (enzyme)

  • shallow(render only parent)

3. Test assertion (enzymes || test)

  • expect().toBeTruthy()

a. Test assertion for functions

  • toHaveBeenCalledTimes() how many times a function called

4. Simalating event

wrapper.find('input').at(1).simulate('change', { target: { name: 'height', value: 70 } });
expect(testState.height).toEqual(70);
  • simulating in Enzyme same as firing event in RTL

5. component.update()


Redux store work flow
  • Redux thunk Middleware
function createThunkMiddleware(extraArgument) { 
return ({ dispatch, getState }) => (next) => (action) => {
if(typeof action === 'function') {
return action(dispatch, getState, extraArgument);
}
return next(action);
};
}
const thunk = createThunkMiddleware();
thunk.withExtraArgument = createThunkMiddleware;
export default thunk;

Git cheat Sheet

Photo by Florian Olivo on Unsplash

Before we discuss differences let have some common characteristics.

Common characteristics

  1. Both are primitive data types

Difference b/w Padding & Margin in CSS

When I was a beginner. Initially, I always confused b/w padding and margin in CSS. Therefore to help beginners, I have written few points that describe the difference b/w padding and margin. So let's begin:-

  • Padding is the difference b/w content(text) of element and border of the same element;

Photo by Kevin Ku on Unsplash

Here I am sharing interview problems topic wise link of leetcode plateform. This is just beginning, I will be sharing other topics list in future. And if you already have list of topics which is not present in this blog please provide link in the comment section.

  1. Graph
Graphs Videos for Beginners.

2. Sliding window

3 Dp


n=(n& ~(1UL<<p))|(value<<p);

Example:

let n=15(1111)

here bit position p is supposed from right to left (3,2,1,0)

p=2

Step 1: x=1UL<<p=100;(clearing the bit at position p)

Step 2: ~x=011(1’s compliment)

Step 3: n&(1UL<<p)=1011;

value =0;

Step 4:value<<p=0;

Step 5:n&(1UL<<p)|(value<<p)=1011;

n=(n&(1UL<<p))|(value<<p)=1011;

c++ function

int modify(int n,int pos,int value){

n=(n&(1UL<<p))|(value<<p);

return n;

}


Given N which describes height of Pyramid

Example: N=5

*
* *
* * *
* * * *
* * * * *

C++ Code:

#include<bits/stdc++.h>
using namespace std;
int printn(int n){
if(n==0)
return 0;
cout<<”* “;
printn(n-1);
}
void fun1(int m,int i){
if(i>m)
return ;
else
printn(i);
cout<<endl;
fun1(m,i+1);
}
int main(){
int n;
cin>>n;
fun1(n,1);
return 0;
}

The program must accept a string S and an integer N as the input. The program must print the desired pattern as shown below:

Examples:

String s=abcdefg ;

N=3;

Pattern:

a

b*

c**

d

e*

f**

g

Code:

/*input
abcdef
3
*/
#include<bits/stdc++.h>
using namespace std;
void printn(int count){
if(count<=0)
return;
cout<<”*”;
printn(count-1);
}
void fun(string s,int i,int n,int count,int val){
if(i>=n)
return;
cout<<s[i];
printn(count%val);
cout<<endl;
fun(s,i+1,n,count+1,val);
}
int main(){
int val;
string s;
cin>>s;
cin>>val;
int n=s.size();
fun(s,0,n,0,val);
}

Arvind Dhakar

Programmer, Developer

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store