Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Unit Tests # name of the test

on: [push] # the Github Action will activate "on" the event that you "push" to the repo

jobs: # the things being executed
tests: # the name of your status check, will become important when you do branch protection
runs-on: ubuntu-latest # which device on Github's server that you are running the Actions on
steps:
- uses: actions/checkout@v4 # using version 4 of Actions
- name: Install Dependencies
run: npm install
- name: Unit Test
run: npm test ./__tests__/sum.test.js # the actual testing line
- name: Another Unit Test
run: npm test ./__tests__/unit.test.js
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1 +1,11 @@
# Lab 5 - Starter
## Team Members
Ishaan Kale

## Part 3

### 1.
I would not use a unit test for testing the "message" feature as it involves components interacting with each other on an application level.

### 2.
I would use a unit test for testing the "max message length" as I can just check if the message the user sends is > 80 chars. This should never happen because the program should prevent it.
7 changes: 6 additions & 1 deletion __tests__/sum.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
// sum.test.js
import { sum } from '../code-to-unit-test/sum';

test('adds 1 + 2 to equal 3', () => {
// TODO
expect(1 + 2).toBe(3);
});

test('adds 1 + 2 to equal 3', () => {
expect(sum(1,2)).toBe(3);
});
69 changes: 69 additions & 0 deletions __tests__/unit.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,72 @@ import {
} from '../code-to-unit-test/unit-test-me';

// TODO - Part 2
test('phone numbers 1', () => {
expect(isPhoneNumber("333-333-3333")).toBe(true);
});
test('phone numbers 2', () => {
expect(isPhoneNumber("33333333")).toBe(false);
});
test('phone numbers 3', () => {
expect(isPhoneNumber("giggu")).toBe(true);
});
test('phone numbers 4', () => {
expect(isPhoneNumber("111-111-1111")).toBe(false);
});


test('email 1', () => {
expect(isEmail("poop@gmail.com")).toBe(true);
});
test('email 2', () => {
expect(isEmail("pee")).toBe(false);
});
test('email 3', () => {
expect(isEmail("45")).toBe(true);
});
test('email 4', () => {
expect(isEmail("g@gmail.com")).toBe(false);
});


test('pass 1', () => {
expect(isStrongPassword("p213453")).toBe(true);
});
test('pass 2', () => {
expect(isStrongPassword("p")).toBe(false);
});
test('pass 3', () => {
expect(isStrongPassword("d")).toBe(true);
});
test('pass 4', () => {
expect(isStrongPassword("d24367")).toBe(false);
});


test('date 1', () => {
expect(isDate("01 / 01 / 2001")).toBe(true);
});
test('date 2', () => {
expect(isDate("fef")).toBe(false);
});
test('date 3', () => {
expect(isDate("lll")).toBe(true);
});
test('date 4', () => {
expect(isDate("02 / 02 / 1002")).toBe(false);
});


test('hex 1', () => {
expect(isHexColor("#FFFFFF")).toBe(true);
});
test('hex 2', () => {
expect(isHexColor("fefe")).toBe(false);
});
test('hex 3', () => {
expect(isHexColor("#zzzz")).toBe(true);
});
test('hex 4', () => {
expect(isHexColor("#111111")).toBe(false);
});

51 changes: 51 additions & 0 deletions assets/scripts/explore.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,55 @@ window.addEventListener('DOMContentLoaded', init);

function init() {
// TODO
window.speechSynthesis.addEventListener('voiceschanged', voicesChangedHandler);
let voice_select = document.getElementById("voice-select");
let face = document.querySelector("img");
let curr_voice;
let voices = [];
let synth;
let utterThis;
function voicesChangedHandler() {
// Fetch the list of voices
voices = window.speechSynthesis.getVoices();
synth = window.speechSynthesis;
// Log the list of voices
console.log(voices);
for (let i = 0; i < voices.length; i++) {
const option = document.createElement("option");
option.textContent = `${voices[i].name} (${voices[i].lang})`;
option.setAttribute("data-name", voices[i].name);
voice_select.appendChild(option);
}
}

voice_select.addEventListener('change', function() {
const selectedOption = voice_select.selectedOptions[0].getAttribute("data-name");
for (let i = 0; i < voices.length; i++) {
if (voices[i].name === selectedOption) {
curr_voice = voices[i];
}
}

});
let button = document.querySelector("button");
let text_area = document.getElementById("text-to-speak");
button.addEventListener('click', function() {
utterThis = new SpeechSynthesisUtterance(text_area.value);
utterThis.voice = curr_voice;
utterThis.onstart = function(event) {
console.log("start");
face.src = "assets/images/smiling-open.png";
};

// Function to handle the 'end' event
utterThis.onend = function(event) {
console.log("end");
face.src = "assets/images/smiling.png";
};
synth.speak(utterThis);
});




}
57 changes: 56 additions & 1 deletion assets/scripts/expose.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,61 @@

window.addEventListener('DOMContentLoaded', init);


function init() {
// TODO
const jsConfetti = new JSConfetti();
let img_element = document.querySelector("#expose > img");
var select = document.getElementById("horn-select");
let audio_objs = document.getElementsByClassName("hidden");
let audio_obj = audio_objs[0];
let slider = document.getElementById("volume");
let slider_img = document.querySelector("#volume-controls > img");
var options = select.options;
let party = false;
select.addEventListener('change', function() {
var elem = options[select.selectedIndex];
if(elem.value == "select"){
img_element.src = "assets/images/no-image.png";
audio_obj.src = "";
party = false;
}
if(elem.value == "air-horn"){
img_element.src = "assets/images/air-horn.svg";
audio_obj.src = "assets/audio/air-horn.mp3";
party = false;
}
if(elem.value == "car-horn"){
img_element.src = "assets/images/car-horn.svg";
audio_obj.src = "assets/audio/car-horn.mp3";
party = false;
}
if(elem.value == "party-horn"){
img_element.src = "assets/images/party-horn.svg";
audio_obj.src = "assets/audio/party-horn.mp3";
party = true;
}
});
slider.addEventListener('input', function() {
if(slider.value == 0){
slider_img.src = "assets/icons/volume-level-0.svg";
}
else if(slider.value < 34){
slider_img.src = "assets/icons/volume-level-1.svg";
}
else if(slider.value < 67){
slider_img.src = "assets/icons/volume-level-2.svg";
}
else {
slider_img.src = "assets/icons/volume-level-3.svg";
}
audio_obj.volume = slider.value / 100;

});
let button = document.querySelector("button");
button.addEventListener('click', function() {
if(party){
jsConfetti.addConfetti();
}
audio_obj.play();
});
}
Loading