Как написать тест на шифрование с помощью react-testing-library - PullRequest
0 голосов
/ 07 августа 2020

У меня есть два метода для шифрования и дешифрования.

import {
    AES,
    enc,
    mode,
    pad,
} from "crypto-js";

const options = {
    mode: mode.CBC,
    padding: pad.Pkcs7
};

export function encrypt(encryptItem: string, secretKey: string) {
    const bytes = AES.encrypt(encryptItem, secretKey, options);
    return bytes.toString();
}

export function decrypt(decryptItem: string, secretKey: string) {
    const bytes = AES.decrypt(decryptItem, secretKey, options);
    return bytes.toString(enc.Utf8);
}

Как мне написать тест, охватывающий эти два метода, используя react-testing-library?

...