Created
April 21, 2020 20:38
-
-
Save windy1/835b66d25c2a47b076f1bb37a6d062ac to your computer and use it in GitHub Desktop.
jslol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const assert = require('assert'); | |
describe('typeof', () => { | |
it('arrays are objects', () => { | |
assert(typeof [] === 'object'); | |
}); | |
it('objects are objects', () => { | |
assert(typeof {} === 'object'); | |
}); | |
it('strings are strings', () => { | |
assert(typeof '' === 'string'); | |
}); | |
it('numbers are numbers', () => { | |
assert(typeof 0 === 'number'); | |
}); | |
it('booleans are booleans', () => { | |
assert(typeof false === 'boolean'); | |
}); | |
it('NaN is a number', () => { | |
assert(typeof NaN === 'number'); | |
}); | |
it('undefined is undefined', () => { | |
assert(typeof undefined === 'undefined'); | |
}); | |
}); | |
describe('instanceof', () => { | |
it('arrays are Arrays', () => { | |
assert([] instanceof Array); | |
}); | |
it('objects are Objects', () => { | |
assert({} instanceof Object); | |
}); | |
it('strings are not Strings', () => { | |
assert(!('' instanceof String)); | |
}); | |
it('numbers are not Numbers', () => { | |
assert(!(0 instanceof Number)); | |
}); | |
it('booleans are not Booleans', () => { | |
assert(!(false instanceof Boolean)); | |
}); | |
}); | |
describe('comparison', () => { | |
describe('double equals', () => { | |
it('the string 2 is equal to the number 2', () => { | |
assert('2' == 2); | |
assert(2 == '2'); | |
}); | |
it('the string 2 is equal to the string 2', () => { | |
assert('2' == '2'); | |
}); | |
it('the number 2 is equal to the number 2', () => { | |
assert(2 == 2); | |
}); | |
it('the array [1, 2, 3] is not equal to the array [1, 2, 3]', () => { | |
assert(!([1, 2, 3] == [1, 2, 3])); | |
}); | |
}); | |
it('the string 1 plus the number 1 is the string 11', () => { | |
assert.equal('1' + 1, '11'); | |
assert.equal(1 + '1', '11'); | |
}); | |
it('the string 2 divided by the number 2 is the number 1', () => { | |
assert.equal('2' / 2, 1); | |
assert.equal(2 / '2', 1); | |
}); | |
it('the string true and the boolean true is the boolean true', () => { | |
assert('true' && true); | |
assert(true && 'true'); | |
}); | |
it('the string true and the string true is the boolean true', () => { | |
assert('true' && 'true'); | |
}); | |
it('the string 1 and the boolean true is the boolean true', () => { | |
assert('1' && true); | |
assert(true && '1'); | |
}); | |
it('the string true or the boolean false is the boolean true', () => { | |
assert('true' || false); | |
assert(false || 'true'); | |
}); | |
it('the string 1 or the boolean false is the boolean true', () => { | |
assert(false || '1'); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment