mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-12-01 12:26:19 -05:00
Moving OTP and Vin decoder to calculators to save Navbar space. Reworking calculators to purpose groups, and adding colors.
This commit is contained in:
parent
c95afc7f62
commit
05bb65fc03
8 changed files with 373 additions and 308 deletions
28
app/src/components/calculators/OneTimePadCalculator.test.js
Normal file
28
app/src/components/calculators/OneTimePadCalculator.test.js
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
import React from "react";
|
||||
import {fireEvent, screen} from "@testing-library/react";
|
||||
import {renderWithProviders} from "../../test-utils";
|
||||
import {OneTimePadCalculator} from "./OneTimePadCalculator";
|
||||
|
||||
describe('OneTimePadCalculator', () => {
|
||||
test('renders the pad tools', () => {
|
||||
renderWithProviders(<OneTimePadCalculator/>);
|
||||
expect(screen.getByText('One-Time Pad')).toBeTruthy();
|
||||
expect(screen.getByText('Generate New Pad')).toBeTruthy();
|
||||
expect(screen.getByText('Encrypt')).toBeTruthy();
|
||||
expect(screen.getByText('Decrypt')).toBeTruthy();
|
||||
});
|
||||
|
||||
test('encrypts live using the entered key', () => {
|
||||
const {container} = renderWithProviders(<OneTimePadCalculator/>);
|
||||
// The Encrypt section's Key and Plaintext textareas are the first two on the page.
|
||||
const keys = container.querySelectorAll('textarea[name="otp"]');
|
||||
const plaintext = container.querySelector('textarea[name="plaintext"]');
|
||||
fireEvent.change(keys[0], {target: {value: 'ABCDE'}});
|
||||
fireEvent.change(plaintext, {target: {value: 'HELLO'}});
|
||||
// Ciphertext is rendered into a <pre> and differs from the plaintext once a key is present.
|
||||
const pres = container.querySelectorAll('pre');
|
||||
const ciphertext = pres[0].textContent;
|
||||
expect(ciphertext).toBeTruthy();
|
||||
expect(ciphertext).not.toEqual('HELLO');
|
||||
});
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue