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
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ language: node_js
node_js:
- "node"
- "iojs"
services:
- "xvfb"
before_script:
- export DISPLAY=:99.0
- sh -e /etc/init.d/xvfb start
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@
},
"homepage": "https://github.com/ahmednuaman/javascript-tests",
"dependencies": {
"karma": "^0.12.32",
"karma-jasmine": "^0.3.5",
"karma-phantomjs-launcher": "^0.1.4"
"jasmine-core": "2.3.4",
"karma": "^0.13.22",
"karma-jasmine": "0.3.5",
"karma-phantomjs-launcher": "1.0.4"
},
"devDependencies": {
"karma-chrome-launcher": "^0.1.12",
Expand Down
3 changes: 2 additions & 1 deletion test/clone-object.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
describe('clone object', function () {
it('should clone an object', function () {
var expected = {name: 'Ahmed', age: 27, skills: ['cycling', 'walking', 'eating']},
obj = {};
// efficient one line to clone objects.
obj = JSON.parse(JSON.stringify(expected));

expect(obj).toEqual(expected);
expect(obj).not.toBe(expected);
Expand Down
8 changes: 7 additions & 1 deletion test/flatten-array.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@ describe('flatten array', function () {
it('should flatten an 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];

// re-write to work with travis, converting the array to a string array and then mapping it as number array, then finally sorting it into the correct order
const stringArr = arr.toString();
const flattenedArr = stringArr.split(',').map(Number);

arr = flattenedArr.sort();

expect(arr).toEqual(expected);
});
});
});
5 changes: 3 additions & 2 deletions test/scoping.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@ describe('scoping', function () {
return this.foo;
};

// explicitely setting the 'this' value
Module.prototype.req = function() {
return request(this.method);
return request(this.method.bind(this));
};

expect(mod.req()).toBe('bar');
});
});
});