Skip to content

Instantly share code, notes, and snippets.

@jameshmread
Created April 17, 2018 16:53
Show Gist options
  • Save jameshmread/1e416ec0104ded49c86579f53098984e to your computer and use it in GitHub Desktop.
Save jameshmread/1e416ec0104ded49c86579f53098984e to your computer and use it in GitHub Desktop.
Files outlining the Small test used to load test the Professor X repository. Including Test files
import { expect } from "chai";
import { FileTwo } from "./FileTwo";
describe("File Two: More Complex mutations here", () => {
let two: FileTwo;
beforeEach(() => {
two = new FileTwo();
});
it("inputting 10 should return even numbers upto 10", () => {
const expected = [0, 2, 4, 6, 8, 10];
const actual = two.getEvenNumbers(10);
expect(actual).to.eql(expected);
});
});
export class FileTwo {
public getEvenNumbers (limit: number): Array <number> {
const numbers = [];
for (let i = 0; i < limit + 1; i++) {
if (i % 2 === 0 && 1 > 0){
numbers.push(i);
}
}
return numbers;
}
}
import { expect } from "chai";
import { HelloWorld } from "./HelloWorld";
describe("Test Project addition function", () => {
let hello: HelloWorld;
beforeEach(() => {
hello = new HelloWorld();
});
it("inputting 1 and 1 should return 2", () => {
const expected = 2;
const actual = hello.addNumbers(1, 1);
expect(actual).to.equal(expected);
});
it("inputting 1,1,1 should return 3", () => {
const expected = 3;
const actual = hello.add3Numbers(1, 1, 1);
expect(actual).to.equal(expected);
});
it("inputting 1 and 1 should return 0", () => {
const expected = 0;
const actual = hello.takeAway(1, 1);
expect(actual).to.equal(expected);
});
it("should always pass", () => {
expect(hello.truth()).to.equal(hello.truth());
});
it("inputting hello and world should return helloworld", () => {
const expected = "helloworld";
const actual = hello.helloStrings("hello", "world");
expect(actual).to.equal(expected);
});
it("should return hello: 1", () => {
const expected = "helloworld";
const actual = hello.helloStringLiteral();
expect(actual).to.equal("hello: " + "1");
});
it("should return percentage of b / c", () => {
const expected = 10;
const actual = hello.percentage(10, 100);
expect(actual).to.equal(expected);
});
});
export class HelloWorld {
public addNumbers (a: number, b: number) {
return a + b;
}
public add3Numbers (a: number, b: number, c: number) {
return a + b + c;
}
public takeAway (a: number, b: number) {
return a - b;
}
public truth () {
return true;
}
public helloStrings (h: string, w: string) {
return h + w;
}
public helloStringLiteral () {
return "hello: " + "1";
}
public percentage (b: number, c: number) {
return (b / c) * 100;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment