Skip to content
Open
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
31 changes: 18 additions & 13 deletions 01-js-basics-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ test('javascript can do basic arithmatic', (t) => {
// to the value that should result in the operation
// on the left
t.equal(4 + 5, 9, "Example of javascript adding.");
t.equal(31 - 5, "WAT", "It can subtract!");
t.equal(6 * 8, "WAT", "It can multiply!");
t.equal((2 + 2) * 2 + 2 * 2, "WAT", "It can chain operations!");
t.equal(31 - 5, 26, "It can subtract!");
t.equal(6 * 8, 48, "It can multiply!");
t.equal((2 + 2) * 2 + 2 * 2, 12, "It can chain operations!");
});

test('javascript can do logic', (t) => {
Expand All @@ -31,11 +31,11 @@ test('javascript can do logic', (t) => {
// on the left
t.equal(1 > 5, false, "It can do Greater than!");
t.equal(1 < 5, true, "It can do Less than!");
t.equal(99 >= 99, "WAT", "It can do Greater than or equal to!");
t.equal(7 === 5, "WAT", "It can do equality!");
t.equal(7 !== 5, "WAT", "It can do inequality!");
t.equal(true && true, "WAT", "It can do logical and");
t.equal(true || false, "WAT", "It can do logical or!");
t.equal(99 >= 99, true, "It can do Greater than or equal to!");
t.equal(7 === 5, false, "It can do equality!");
t.equal(7 !== 5, true, "It can do inequality!");
t.equal(true && true, true, "It can do logical and");
t.equal(true || false, true, "It can do logical or!");
});


Expand All @@ -44,8 +44,11 @@ test('javascript has arrays', (t) => {
t.equal([1, 2, 4].length, 3, "An array with three items has a lenght of three");

const a = [1, 2, 4];
t.equal(a[0], "WAT", "Arrays in javascript are indexed started with zero");
t.equal(a.pop(), "WAT", "Arrays have useful methods that can be called on");
t.equal(a[0], 1, "Arrays in javascript are indexed started with zero");
t.equal(a.pop(), 4, "Arrays have useful methods that can be called on");
t.equal(1,1, 'hi');

t.end();
});


Expand All @@ -60,9 +63,11 @@ test('javascript has objects', (t) => {
}
};

t.equal(book.title, "WAT", "You can access properties on an object");
t.equal(book.yearPublished, "WAT", "You can store any type of data on an object");
t.equal(book.randoFunction(), "WAT", "Including a function");
t.equal(book.title, 'everybody poops', "You can access properties on an object");
t.equal(book.yearPublished, 1995, "You can store any type of data on an object");
t.equal(book.randoFunction(), 8, "Including a function");

t.end();
});