Base js tests
by Konrad Bloor
HTML
<link rel="stylesheet" href="https://cdn.jsdelivr.net/jasmine/1.3.1/jasmine.css">
<script src="https://cdn.jsdelivr.net/jasmine/1.3.1/jasmine.js"></script>
<script src="https://cdn.jsdelivr.net/jasmine/1.3.1/jasmine-html.js"></script>
JavaScript
// ************************************************************************************************************************************
// instructions:
// 0. Dont Panic
// notes:
// * This is not timed, complete at your own pace.
// * You may use any resources you like, but you need to be able to explain your answers.
// * Consult the TODO comments for instructions.
// * Do not modify expect() calls unless there is an INCOMPLETE value. This is how each test is judged for correctness.
// * After each edit, the tests should re-run automatically. (a green dot instead of a red X indicates success).
// ************************************************************************************************************************************
describe("can we", function () {
"use strict";
it("understand bools", function() {
// some people just don't get bools. prove to me that you do.
function boolean(x, y) {
// todo: write a function that returns true if the value of x is true, or the value of y is 10, otherwise return false.
return ;
}
expect(boolean(true, 99)).toBe(true);
expect(boolean(false, 10)).toBe(true);
expect(boolean(false, 99)).toBe(false);
});
it("write a for loop", function() {
var sum = 0;
// TODO: write a 'for' loop which sums the EVEN numbers in the range [1 to 50] (inclusive)
expect(sum).toBe(650);
});
it("understand object literals", function() {
// TODO: declare an object which has the fields 'name' and 'age'
// set name to "Bob" and age to 30
expect(p.name).toBe("Bob");
expect(p.age).toBe(30);
});
it("solve generic interview type questions", function () {
function palindrome(possiblePalindrome) {
// TODO: Write a function which tests an input string to determine whether it is the same forwards and backwards.
}
expect(palindrome("rats live on no evil star")).toBe(true);
...