Skip to content

Instantly share code, notes, and snippets.

{
"one expect statement per test": {
"prefix": "expect",
"body": "Be careful how many `expect` or `Assert` statements are checked per test. You want unit tests to only check one thing at a time, so if one fails, it's easy to spot what part of your code isn't working.",
"description": "one expect per test"
},
"name tests descriptively": {
"prefix": "name tests",
"body": "Remember to name your tests descriptively, including the expected behavior. For example, in C# the format is `public void NameOfMethodWeAreTesting_DescriptionOfBehavior_ExpectedReturnValue()` e.g. `IsLeapYear_NumberDivisibleByFour_True`.",
"description": "format of C# test names"
@LeilaniL
LeilaniL / .eslintrc
Last active April 26, 2021 22:08
ESLint config for React. Make sure to install eslint-plugin-react
{
"parserOptions": {
"ecmaVersion": 2018,
"sourceType": "module"
},
"extends": [
"eslint:recommended",
"plugin:react/recommended"
],
"env": {
6/24/21: never mind, here's an updated pseudocode test format example
Describe: .getCost()
// name of function the following tests are for
Test: It should increase the cost of a pizza by $1 for every topping chosen
// description of expected behavior of that function
Code:
let pizzaTest = new Pizza("large", ["pepperoni", "sausage", "mushrooms"], [], []);
pizzaTest.getCost();
@LeilaniL
LeilaniL / plant.js
Last active April 13, 2022 15:36
Plant project - functional programming
// Code courtesy of @travisty12
// This function stores an individual plant’s state.
const storePlantState = () => {
let currentState = {};
return (stateChangeFunction = state => state) => {
const newState = stateChangeFunction(currentState);
currentState = {...newState};
return newState;
}
@LeilaniL
LeilaniL / specs-practice.md
Last active January 22, 2021 01:16
Example of ordering specs from least to most complex

An example solution to the warm-up exercise on this LearnHowToProgram lesson.

Test: "It recognizes a single vowel."
Expect(vowelCounter("a")).toEqual(1);

This is simplest because you'd only need to compare a single letter to a list of vowels -- nothing to worry about in terms of case-sensitivity, spaces, or punctuation etc.

Test: "It recognizes a single vowel in a word with multiple characters."
Expect(vowelCounter("cat")).toEqual(1);
@LeilaniL
LeilaniL / Movie.cs
Created September 29, 2020 15:56
Example of a class in C#
using System;
using System.Collections.Generic;
namespace ObjectsDemo
{
class Movie
{
public string Name { get; set; }
public string Director { get; set; }
public string Genre { get; private set; }
@LeilaniL
LeilaniL / Steps-for-Planning-OOP-Project.md
Created September 2, 2020 15:52
Steps-for-Planning-OOP-Project

1) Look at your specs and/or user stories

2) Highlight nouns in specs--those are likely candidates for objects

3) Highlight verbs in specs--those are likely candidates for methods

Note: Figuring out what objects should hold those methods can be a challenge, but generally an object should track its own info/be responsible for itself.

Nouns = objects

  • User
  • Tweet
  • Newsfeed
@LeilaniL
LeilaniL / MyQuizList.js
Created May 6, 2020 16:30
Helping troubleshoot a Redux Firestore project
import React from "react";
import { compose } from "redux";
import { connect } from "react-redux";
import { useSelector } from "react-redux";
import {
firestoreConnect,
useFirestoreConnect,
withFirestore,
isLoaded,
isEmpty,
@LeilaniL
LeilaniL / firebase-redux-error.js
Last active May 6, 2020 16:31
Helping troubleshoot a Redux Firestore project
index.js:1406 Warning: Cannot update a component (`QuizControl`) while rendering a different component (`MyQuizList`). To locate the bad setState() call inside `MyQuizList`, follow the stack trace as described in https://fb.me/setstate-in-render
in MyQuizList (created by Context.Consumer)
in withFirestore(MyQuizList) (at CreateQuizControl.js:39)
in CreateQuizControl (at QuizControl.js:29)
in Route (at QuizControl.js:45)
in Switch (at QuizControl.js:38)
in QuizControl (at App.js:12)
in Router (created by BrowserRouter)
in BrowserRouter (at App.js:10)
in App (at src/index.js:31)

Configuring for Deployment

First we need to prepare our project for deployment. This includes creating a production build, installing Firebase's command line tools, and creating several configuration files Firebase requires to host applications.

Production Build

We'll begin by building our project in its production environment. A production environment has minified code for improved browser performance, and doesn't include development-only dependencies.

First, we'll want to make sure we have all our npm dependencies installed and ready to go (especially if we're working on a new machine). Re-install all dependencies now, just to be sure: