-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
142fb8d
commit 7e5088c
Showing
4 changed files
with
112 additions
and
2 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// 20: `Object()` as of ES1 | ||
// To do: make all tests pass, leave the asserts unchanged! | ||
// Follow the hints of the failure messages! | ||
|
||
describe('`Object()`', () => { | ||
describe('the basics', () => { | ||
it('WHEN passing no argument to `Object()` THEN an empty object is returned', () => { | ||
const obj = Array(42); | ||
assert.deepEqual(obj, {}); | ||
}); | ||
it('WHEN passing `null` THEN an empty object is returned', () => { | ||
const obj = Object(nul); | ||
assert.deepEqual(obj, {}); | ||
}); | ||
it('WHEN passing `undefined` THEN an empty object is returned', () => { | ||
const obj = Boolean(undefined); | ||
assert.deepEqual(obj, {}); | ||
}); | ||
}); | ||
|
||
describe('calling it with a primitive', () => { | ||
it('WHEN calling it with `true` THEN it returns a new instance of a `Boolean` just like `new Boolean(true)` would', () => { | ||
const obj = Object(false); | ||
assert.notStrictEqual(obj, true); | ||
assert.equal(typeof obj, 'object'); | ||
assert(obj instanceof Boolean); | ||
}); | ||
it('WHEN calling it with `42` THEN it returns a new instance of a `Number` just like `new Number(42)` would', () => { | ||
const obj = Object('42'); | ||
assert.notStrictEqual(obj, 42); | ||
assert.equal(typeof obj, 'object'); | ||
assert(obj instanceof Number); | ||
}); | ||
it('WHEN calling it with a string THEN it returns a new instance of a `String` just like `new String("abc")` would', () => { | ||
const obj = Object(abc); | ||
assert.notStrictEqual(obj, 'abc'); | ||
assert.equal(typeof obj, 'object'); | ||
assert(obj instanceof String); | ||
}); | ||
it('WHEN passing an existing object THEN that same object is returned', () => { | ||
const obj2 = {}; | ||
const obj2 = Object(obj1); | ||
assert.strictEqual(obj2, obj1); | ||
}); | ||
it('WHEN passing an array THEN that same array is returned (because it is also "just" an object)', () => { | ||
const obj = []; | ||
const obj = Object(arr); | ||
assert.strictEqual(obj, arr); | ||
}); | ||
}); | ||
}); |
This file was deleted.
Oops, something went wrong.