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
Empty file added .babelrc
Empty file.
32 changes: 32 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"test": "echo\"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
Expand Down
54 changes: 54 additions & 0 deletions src/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
//base class
class Vehicle{
constructor(color,type,year){
this.name='Vehicle';
this.color =color;
this.type =type;
this.year =year;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These variables are not private

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, with the way you assigned 'Vehicle' to this.name. that means all classes inherited will always have 'vehicle' as the name. I'm not sure that's what you intended to do.

}
accelerate(){
return this.name+"move forward";
}


}
//instatiating a car model of a vehicle
let v = new Vehicle(red,car);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not a good variable name, variable names should be descriptive

return "This is a " + v.red +v.name;



//inheritance to class 'car' from class 'vehicle'
class Car extends Vehicle{
constructor(color,type,year){
super();
this.color=color;
this.type=type;
this.year =year;

}
}
//encapsulating the class Car into toyota
let toyota = new Car('red','new',2012);



class Truck extends Vehicle{
constructor(color,type,year){
super();
this.color=color;
}
accelerate(){
return this.name+"move forward";
}

}

let Hiace = new Truck






Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Always end your files with a new line

18 changes: 18 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import chai from 'chai'
import app from '../src/main';
let assert = chai.assert;

describe('app to test as', () => {
let result = app();
it('app should return hello', () => {

assert.equal(result, 'hello')
}); // we put app() becos we checking for app()----goto terminal type npm run test

it('it should be a string', () => {
assert.typeOf(result, 'string')
});
});

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You wrote tests but your tests are not running because you didn't update your package.json with the test script