This file contains hidden or 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
// Using compare method as example | |
const bcryptCompare = jest.fn().mockRejectedValue(new Error('Random error')); | |
(bcrypt.compare as jest.Mock) = bcryptCompare; | |
//call method that uses bcrypt.compare with async | |
const bcryptCompare = jest.fn().mockResolvedValue(true); | |
(bcrypt.compare as jest.Mock) = bcryptCompare; | |
//call method that uses bcrypt.compare with async |
This file contains hidden or 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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>File Uploader</title> | |
<style> | |
.container { | |
width: 100%; | |
height: 100%; |
This file contains hidden or 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.*; | |
class LongestSubstringKDistinct { | |
public static int findLength(String str, int k) { | |
int windowStart = 0, maxLength = 0; | |
Map<Character, Integer> charFrequencyMap = new HashMap<>(); | |
for (int windowEnd = 0; windowEnd < str.length(); windowEnd++) { | |
char rightChar = str.charAt(windowEnd); | |
charFrequencyMap.put(rightChar, charFrequencyMap.getOrDefault(rightChar, 0) + 1); |