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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,5 @@ build/Release
# Deployed apps should consider commenting this line out:
# see https://npmjs.org/doc/faq.html#Should-I-check-my-node_modules-folder-into-git
node_modules

package-lock.json
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,12 @@
},
"homepage": "https://github.com/ahmednuaman/javascript-tests",
"dependencies": {
"karma": "^0.12.32",
"karma": "^5.2.3",
"karma-jasmine": "^0.3.5",
"karma-phantomjs-launcher": "^0.1.4"
"karma-phantomjs-launcher": "^1.0.4"
},
"devDependencies": {
"jasmine-core": "^3.6.0",
"karma-chrome-launcher": "^0.1.12",
"karma-firefox-launcher": "^0.1.6"
}
Expand Down
4 changes: 3 additions & 1 deletion test/clone-object.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ describe('clone object', function () {
var expected = {name: 'Ahmed', age: 27, skills: ['cycling', 'walking', 'eating']},
obj = {};

obj = JSON.parse(JSON.stringify(expected));

expect(obj).toEqual(expected);
expect(obj).not.toBe(expected);
});
});
});
13 changes: 13 additions & 0 deletions test/flatten-array.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,19 @@ describe('flatten array', function () {
var arr = [1, 2, [1, 2, [3, 4, 5, [1]]], 2, [2]],
expected = [1, 1, 1, 2, 2, 2, 2, 3, 4, 5];

// arr.flat() does not work on IE

function flatten(array) {
if (array instanceof Array) {
return array.length === 0
? []
: flatten(array[0]).concat(flatten(array.slice(1)));
}
return [array];
}

arr = flatten(arr).sort();

expect(arr).toEqual(expected);
});
});
2 changes: 1 addition & 1 deletion test/scoping.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ describe('scoping', function () {
};

Module.prototype.req = function() {
return request(this.method);
return request(this.method.bind(this));
};

expect(mod.req()).toBe('bar');
Expand Down