This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as reactModule from "react"; | |
import { shallow } from "enzyme"; | |
import EffectComponent from "./EffectComponent"; | |
describe("test App Component", () => { | |
it("should call the logic in useEffect", () => { | |
const setDataSize = jest.fn(size => {}); | |
reactModule.useState = jest.fn(initialDataSize => [ | |
initialDataSize, | |
setDataSize |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { useState, useEffect } from "react"; | |
export default function EffectComponent() { | |
const [dataSize, setDataSize] = useState(0); | |
const loadData = () => { | |
const dataFromApi = ['a', 'b', 'c']; | |
setDataSize(dataFromApi.length); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as reactModule from "react"; | |
import { shallow } from "enzyme"; | |
import MultipleStatesComponent from "./MultipleStatesComponent"; | |
describe("test multiple state in component", () => { | |
let wrapper; | |
let setDataLength; | |
let setLoading; | |
let setText; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { useState } from "react"; | |
export default function MultipleStatesComponent() { | |
const [dataLength, setDataLength] = useState(0); | |
const [loading, setLoading] = useState(false); | |
const [text, setText] = useState(""); | |
const handleButtonOne = () => { | |
setDataLength(10); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as reactModule from "react"; | |
import { shallow } from "enzyme"; | |
import ConditionalComponent from "./ConditionalComponent"; | |
describe("test Conditional component", () => { | |
it("should render while loading", () => { | |
const loadingValue = true; | |
reactModule.useState = jest.fn(initialLoadingValue => [ | |
loadingValue, | |
() => {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { useState } from "react"; | |
export default function ConditionalComponent() { | |
const [loading, setLoading] = useState(false); | |
return ( | |
<div> | |
<h1>Conditional test</h1> | |
{loading ? <p>Loading....</p> : <p>Page loaded successfully</p>} | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#run sudo bash devSetup.sh | |
if [ "$EUID" -ne 0 ] | |
then echo "Please run as root/sudo " | |
exit 1 | |
fi | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// you can also use imports, for example: | |
// import java.util.*; | |
// you can write to stdout for debugging purposes, e.g. | |
// System.out.println("this is a debug message"); | |
class Solution { | |
public int solution(int[] A, int K, int L) { | |
// write your code in Java SE 8 | |
if(K + L > A.length){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.HashSet; | |
import java.util.Optional; | |
import java.util.Set; | |
import java.util.stream.Collectors; | |
public class Solution { | |
public static void main(String args[]) throws Exception { | |
/* Enter your code here. Read input from STDIN. Print output to STDOUT */ | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.BufferedReader; | |
import java.io.InputStreamReader; | |
import java.util.ArrayList; | |
import java.util.HashMap; | |
import java.util.List; | |
import java.util.Map; | |
import java.util.stream.Collectors; | |
import java.util.stream.IntStream; |
NewerOlder