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
1 change: 1 addition & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions spec/conditional-flow/boolean-conditions.spec.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
const { a } = require('../../src/conditional-flow/boolean-conditions')
const { a } = require("../../src/conditional-flow/boolean-conditions");

describe("Boolean conditions getResult:", () => {
it("Returns 'Well done, you passed!' with true", () => {
expect(a(true)).toEqual('Well done, you passed!')
})
expect(a(true)).toEqual("Well done, you passed!");
});
it("Returns 'Sorry, try again' with false", () => {
expect(a(false)).toEqual('Sorry, try again')
})
})
expect(a(false)).toEqual("Sorry, try again");
});
});
93 changes: 46 additions & 47 deletions spec/conditional-flow/multiple-conditions.spec.js
Original file line number Diff line number Diff line change
@@ -1,66 +1,65 @@
const {a, b, c} = require('../../src/conditional-flow/multiple-conditions')
const { a, b, c } = require("../../src/conditional-flow/multiple-conditions");

describe("Multiple Conditions isInRange:", () => {
it("4 is between 1 and 6", () => {
expect(a(4, 1, 6)).toEqual(true)
})
expect(a(4, 1, 6)).toEqual(true);
});
it("10 is not between 1 and 5", () => {
expect(a(10, 1, 5)).toEqual(false)
})
expect(a(10, 1, 5)).toEqual(false);
});
it("10 is between 1 and 10", () => {
expect(a(10, 1, 10)).toEqual(true)
})
expect(a(10, 1, 10)).toEqual(true);
});
it("8 is between 8 and 8", () => {
expect(a(8, 8, 8)).toEqual(true)
})
})
expect(a(8, 8, 8)).toEqual(true);
});
});

describe("Multiple Conditions isHelloOrGoodbye:", () => {
it("'Hello' returns true", () => {
expect(b('Hello')).toEqual(true)
})
expect(b("Hello")).toEqual(true);
});

it("'Hey!' returns false", () => {
expect(b('Hey!')).toEqual(false)
})
expect(b("Hey!")).toEqual(false);
});

it("'Goodbye' returns true", () => {
expect(b('Goodbye')).toEqual(true)
})
})
expect(b("Goodbye")).toEqual(true);
});
});

describe("Multiple Conditions getAgeDescription:", () => {
it("0 is a Baby", () => {
expect(c(0)).toEqual("Baby")
})
expect(c(0)).toEqual("Baby");
});
it("1-4 is a Toddler", () => {
expect(c(1)).toEqual("Toddler")
expect(c(2)).toEqual("Toddler")
expect(c(3)).toEqual("Toddler")
expect(c(4)).toEqual("Toddler")
})
expect(c(1)).toEqual("Toddler");
expect(c(2)).toEqual("Toddler");
expect(c(3)).toEqual("Toddler");
expect(c(4)).toEqual("Toddler");
});
it("5-12 is a Child", () => {
expect(c(5)).toEqual("Child")
expect(c(6)).toEqual("Child")
expect(c(7)).toEqual("Child")
expect(c(9)).toEqual("Child")
expect(c(10)).toEqual("Child")
expect(c(11)).toEqual("Child")
expect(c(12)).toEqual("Child")
})
expect(c(5)).toEqual("Child");
expect(c(6)).toEqual("Child");
expect(c(7)).toEqual("Child");
expect(c(9)).toEqual("Child");
expect(c(10)).toEqual("Child");
expect(c(11)).toEqual("Child");
expect(c(12)).toEqual("Child");
});
it("13-19 is a Teenager", () => {
expect(c(13)).toEqual("Teenager")
expect(c(14)).toEqual("Teenager")
expect(c(15)).toEqual("Teenager")
expect(c(16)).toEqual("Teenager")
expect(c(17)).toEqual("Teenager")
expect(c(18)).toEqual("Teenager")
expect(c(19)).toEqual("Teenager")
})
expect(c(13)).toEqual("Teenager");
expect(c(14)).toEqual("Teenager");
expect(c(15)).toEqual("Teenager");
expect(c(16)).toEqual("Teenager");
expect(c(17)).toEqual("Teenager");
expect(c(18)).toEqual("Teenager");
expect(c(19)).toEqual("Teenager");
});
it("20+ is an Adult", () => {
expect(c(20)).toEqual("Adult")
expect(c(25)).toEqual("Adult")
expect(c(40)).toEqual("Adult")
})

})
expect(c(20)).toEqual("Adult");
expect(c(25)).toEqual("Adult");
expect(c(40)).toEqual("Adult");
});
});
48 changes: 24 additions & 24 deletions spec/conditional-flow/numeric-conditions.spec.js
Original file line number Diff line number Diff line change
@@ -1,46 +1,46 @@
const {a, b, c} = require('../../src/conditional-flow/numeric-conditions')
const { a, b, c } = require("../../src/conditional-flow/numeric-conditions");

describe("Numeric Conditions isArrayEmpty:", () => {
it("[] is empty", () => {
expect(a([])).toEqual(true)
})
expect(a([])).toEqual(true);
});
it("[1] is not empty", () => {
expect(a([1])).toEqual(false)
})
expect(a([1])).toEqual(false);
});

it("['hello', 'Ed'] is not empty", () => {
expect(a(['hello', 'Ed'])).toEqual(false)
})
})
expect(a(["hello", "Ed"])).toEqual(false);
});
});

describe("Numeric conditions isGreaterThan:", () => {
it("3 is greater than 2", () => {
expect(b(3, 2)).toEqual(true)
})
expect(b(3, 2)).toEqual(true);
});

it("0 is not greater than 10", () => {
expect(b(0, 10)).toEqual(false)
})
expect(b(0, 10)).toEqual(false);
});

it("42 is not greater than 42", () => {
expect(b(42, 42)).toEqual(false)
})
expect(b(42, 42)).toEqual(false);
});

it("-1 is greater than -3", () => {
expect(b(-1, -3)).toEqual(true)
})
})
expect(b(-1, -3)).toEqual(true);
});
});

describe("Numeric Conditions findLowest:", () => {
it("1 is lowest in [10, 8, 4, 1, 8]", () => {
expect(c([10, 8, 4, 1, 8])).toEqual(1)
})
expect(c([10, 8, 4, 1, 8])).toEqual(1);
});

it("-10 is lowest in [0, 0, -10]", () => {
expect(c([0, 0, -10])).toEqual(-10)
})
expect(c([0, 0, -10])).toEqual(-10);
});

it("100 is lowest in [100,100,100,100]", () => {
expect(c([100, 100, 100])).toEqual(100)
})
})
expect(c([100, 100, 100])).toEqual(100);
});
});
162 changes: 84 additions & 78 deletions spec/conditional-flow/string-conditions.spec.js
Original file line number Diff line number Diff line change
@@ -1,104 +1,110 @@
const { a, b, c, d, e, f } = require('../../src/conditional-flow/string-conditions')
const {
a,
b,
c,
d,
e,
f,
} = require("../../src/conditional-flow/string-conditions");

describe("String Conditions isHello:", () => {
it("Returns false with 'goodbye'", () => {
expect(a("goodbye")).toEqual(false)
})
expect(a("goodbye")).toEqual(false);
});
it("Returns true with 'Hello'", () => {
expect(a("Hello")).toEqual(true)
})
})
expect(a("Hello")).toEqual(true);
});
});

describe("String Conditions isNotHello:", () => {
it("Returns true with 'goodbye'", () => {
expect(b("goodbye")).toEqual(true)
})
expect(b("goodbye")).toEqual(true);
});
it("Returns false with 'Hello'", () => {
expect(b("Hello")).toEqual(false)
})
})
expect(b("Hello")).toEqual(false);
});
});

describe("String Conditions isLongerThan:", () => {
it("'Mike' is longer than 'Ed'", () => {
expect(c("Mike", "Ed")).toEqual(true)
})
expect(c("Mike", "Ed")).toEqual(true);
});
it("'Mike' is not longer than 'Lewis'", () => {
expect(c("Mike", "Lewis")).toEqual(false)
})
expect(c("Mike", "Lewis")).toEqual(false);
});
it("'Mike' is not longer than 'Mike'", () => {
expect(c("Mike", "Mike")).toEqual(false)
})
})
expect(c("Mike", "Mike")).toEqual(false);
});
});

describe("String Conditions hasOddNumberVowels:", () => {
it("'Alex' does not have odd number vowels", () => {
expect(d("Alex")).toEqual(false)
})
expect(d("Alex")).toEqual(false);
});
it("'Mo' does have odd number vowels", () => {
expect(d("Mo")).toEqual(true)
})
expect(d("Mo")).toEqual(true);
});
it("'Joanna' does have odd number vowels", () => {
expect(d("Joanna")).toEqual(true)
})
expect(d("Joanna")).toEqual(true);
});
it("'Maggie Smith' does not have odd number vowels", () => {
expect(d("Maggie Smith")).toEqual(false)
})
})
expect(d("Maggie Smith")).toEqual(false);
});
});

describe("String conditions getMiddleLetter:", () => {
it("'Alex' returns 'le'", () => {
expect(e("Alex")).toEqual('le')
})
expect(e("Alex")).toEqual("le");
});
it("'Edward' returns 'wa'", () => {
expect(e("Edward")).toEqual('wa')
})
expect(e("Edward")).toEqual("wa");
});
it("'Kayla' returns 'y'", () => {
expect(e("Kayla")).toEqual('y')
})
expect(e("Kayla")).toEqual("y");
});
it("'Tom' returns 'o'", () => {
expect(e("Tom")).toEqual('o')
})
})

describe('String conditions seasonForMonth:', () => {
it('January is Winter', () => {
expect(f('January')).toEqual('Winter')
})
it('February is Winter', () => {
expect(f('February')).toEqual('Winter')
})
it('March is Spring', () => {
expect(f('March')).toEqual('Spring')
})
it('April is Spring', () => {
expect(f('April')).toEqual('Spring')
})
it('May is Spring', () => {
expect(f('May')).toEqual('Spring')
})
it('June is Summer', () => {
expect(f('June')).toEqual('Summer')
})
it('July is Summer', () => {
expect(f('July')).toEqual('Summer')
})
it('August is Summer', () => {
expect(f('August')).toEqual('Summer')
})
it('September is Autumn', () => {
expect(f('September')).toEqual('Autumn')
})
it('October is Autumn', () => {
expect(f('October')).toEqual('Autumn')
})
it('November is Autumn', () => {
expect(f('November')).toEqual('Autumn')
})
it('December is Winter', () => {
expect(f('December')).toEqual('Winter')
})
it('Marchprilvember is empty', () => {
expect(f('Marchprilvember')).toEqual('')
})
})
expect(e("Tom")).toEqual("o");
});
});

describe("String conditions seasonForMonth:", () => {
it("January is Winter", () => {
expect(f("January")).toEqual("Winter");
});
it("February is Winter", () => {
expect(f("February")).toEqual("Winter");
});
it("March is Spring", () => {
expect(f("March")).toEqual("Spring");
});
it("April is Spring", () => {
expect(f("April")).toEqual("Spring");
});
it("May is Spring", () => {
expect(f("May")).toEqual("Spring");
});
it("June is Summer", () => {
expect(f("June")).toEqual("Summer");
});
it("July is Summer", () => {
expect(f("July")).toEqual("Summer");
});
it("August is Summer", () => {
expect(f("August")).toEqual("Summer");
});
it("September is Autumn", () => {
expect(f("September")).toEqual("Autumn");
});
it("October is Autumn", () => {
expect(f("October")).toEqual("Autumn");
});
it("November is Autumn", () => {
expect(f("November")).toEqual("Autumn");
});
it("December is Winter", () => {
expect(f("December")).toEqual("Winter");
});
it("Marchprilvember is empty", () => {
expect(f("Marchprilvember")).toEqual("");
});
});
Loading