Skip to content

Commit 0a7a916

Browse files
committed
added ts and js code coverage
1 parent 9148fa6 commit 0a7a916

File tree

7 files changed

+140
-8
lines changed

7 files changed

+140
-8
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@
22
*.log
33
node_modules
44
coverage
5+
.nyc_output
6+
coverage.lcov

.travis.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ install:
55
- npm install
66
script:
77
- npm run go
8-
after_script:
9-
- "cat coverage/lcov.info | node_modules/coveralls/bin/coveralls.js"
8+
after_success:
9+
- npm run nyc-report
1010
notifications:
1111
email:
1212
on_failure: change

dist/js/data-structures/stack.js

+69
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
"use strict";
2+
3+
Object.defineProperty(exports, "__esModule", {
4+
value: true
5+
});
6+
7+
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
8+
9+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
10+
11+
var Stack = function () {
12+
var items = void 0;
13+
14+
var DS = function () {
15+
function DS() {
16+
_classCallCheck(this, DS);
17+
18+
items = [];
19+
}
20+
21+
_createClass(DS, [{
22+
key: "push",
23+
value: function push(element) {
24+
items.push(element);
25+
}
26+
}, {
27+
key: "pop",
28+
value: function pop() {
29+
return items.pop();
30+
}
31+
}, {
32+
key: "peek",
33+
value: function peek() {
34+
return items[items.length - 1];
35+
}
36+
}, {
37+
key: "isEmpty",
38+
value: function isEmpty() {
39+
return items.length === 0;
40+
}
41+
}, {
42+
key: "size",
43+
value: function size() {
44+
return items.length;
45+
}
46+
}, {
47+
key: "clear",
48+
value: function clear() {
49+
items = [];
50+
}
51+
}, {
52+
key: "toArray",
53+
value: function toArray() {
54+
return items;
55+
}
56+
}, {
57+
key: "toString",
58+
value: function toString() {
59+
return items.toString();
60+
}
61+
}]);
62+
63+
return DS;
64+
}();
65+
66+
return DS;
67+
}();
68+
69+
exports.default = Stack;

dist/ts/data-structures/stack.js

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
"use strict";
2+
Object.defineProperty(exports, "__esModule", { value: true });
3+
class Stack {
4+
constructor() {
5+
this.items = [];
6+
}
7+
push(element) {
8+
this.items.push(element);
9+
}
10+
pop() {
11+
return this.items.pop();
12+
}
13+
peek() {
14+
return this.items[this.items.length - 1];
15+
}
16+
isEmpty() {
17+
return this.items.length === 0;
18+
}
19+
size() {
20+
return this.items.length;
21+
}
22+
clear() {
23+
this.items = [];
24+
}
25+
toArray() {
26+
return this.items;
27+
}
28+
toString() {
29+
return this.items.toString();
30+
}
31+
}
32+
exports.default = Stack;

dist/ts/index.js

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
"use strict";
2+
Object.defineProperty(exports, "__esModule", { value: true });
3+
const stack_1 = require("./data-structures/stack");
4+
exports.Stack = stack_1.default;

lib/ts/index.ts

-3
This file was deleted.

package.json

+31-3
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,42 @@
1515
"homepage": "https://github.com/loiane/javascript-datastructures-algorithms",
1616
"scripts": {
1717
"gulp": "gulp",
18-
"clean": "rm -rf ./dist; mkdir ./dist",
18+
"clean": "rm -rf ./dist; mkdir ./dist rm; rm -rf ./coverage",
1919
"build:js": "babel lib/js --presets babel-preset-es2015 --out-dir dist/js",
2020
"build:ts": "tsc",
2121
"build": "npm run build:js && npm run build:ts",
2222
"test:js": "mocha --compilers js:babel-core/register --colors --recursive ./test/js/**/*.spec.js",
2323
"test:ts": "mocha -r ts-node/register --colors --recursive ./test/ts/**/*.spec.ts",
2424
"test": "npm run test:js && npm run test:ts",
25-
"coverage": "./node_modules/.bin/istanbul cover --include-all-sources --root ./lib/js ./node_modules/.bin/_mocha --recursive ./test/js/**/*.spec.js -- --compilers js:babel-core/register && codecov",
26-
"go": "npm run clean && npm run test && npm run build && npm run coverage"
25+
"coverage:js": "./node_modules/.bin/istanbul cover --include-all-sources --root ./lib/js ./node_modules/.bin/_mocha --recursive ./test/js/**/*.spec.js -- --compilers js:babel-core/register",
26+
"nyc-report": "npm run coverage && nyc report --reporter=text-lcov > coverage.lcov && codecov",
27+
"cover:local": "npm run coverage && nyc report --reporter=text",
28+
"coverage": "NODE_ENV=test nyc --report-dir coverage/tscov npm run test",
29+
"go": "npm run clean && npm run build && npm run test"
30+
31+
},
32+
"nyc": {
33+
"include": [
34+
"lib/ts/*.ts",
35+
"lib/ts/**/*.ts",
36+
"lib/js/*.js",
37+
"lib/js/**/*.js"
38+
],
39+
"exclude": [
40+
"typings"
41+
],
42+
"extension": [
43+
".ts",
44+
".js"
45+
],
46+
"require": [
47+
"ts-node/register"
48+
],
49+
"reporter": [
50+
"json",
51+
"html"
52+
],
53+
"all": true
2754
},
2855
"devDependencies": {
2956
"@types/chai": "^4.0.4",
@@ -45,6 +72,7 @@
4572
"gulp": "^3.9.1",
4673
"istanbul": "^v1.1.0-alpha.1",
4774
"mocha": "^3.5.0",
75+
"nyc": "^11.2.1",
4876
"ts-node": "^3.3.0",
4977
"tslint": "^5.7.0",
5078
"typescript": "^2.5.2",

0 commit comments

Comments
 (0)