Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rickithadi/tests #16

Merged
merged 4 commits into from
Oct 3, 2020
Merged
Show file tree
Hide file tree
Changes from 3 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 .tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "es5",
"noImplicitAny": true,
"removeComments": true,
"preserveConstEnums": true,
Expand All @@ -11,4 +12,4 @@
},
"include": ["src/*"],
"exclude": ["node_modules", "**/*.spec.ts"]
}
}
16 changes: 14 additions & 2 deletions dist/cli.js

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

2 changes: 1 addition & 1 deletion dist/cli.js.map

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

33 changes: 30 additions & 3 deletions dist/spacecraft.js

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

2 changes: 1 addition & 1 deletion dist/spacecraft.js.map

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

42 changes: 27 additions & 15 deletions src/spacecraft.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,34 @@
export default class Spacecraft {
public x: number = 0;
public y: number = 0;

public x: number = 0;
public y: number = 0;
public constructor(x: number, y: number) {
this.x = x;
this.y = y;
}

public constructor(x: number, y: number) {
this.x = x;
this.y = y;
}
public get X() {
return this.x;
}

public get X() {
return this.x;
}
public get Y() {
return this.y;
}

public get Y() {
return this.y;
}
createMessage(): string {
return 'Starter point Spacecraft CLI';
}
forward(y: number): number {
return y + 1;
}
back(y: number): number {
return y - 1;
}

createMessage(): string {
return 'Starter point Spacecraft CLI';
}
left(x: number): number {
return x - 1;
}
right(x: number): number {
return x + 1;
}
}
15 changes: 14 additions & 1 deletion tests/spacecraft.spec.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,22 @@
import SpaceCraft from '../src/spacecraft';

describe('Spacecraft', () => {
const spaceCraft = new SpaceCraft();
const spaceCraft = new SpaceCraft(0, 0);

it('displays starter point message', () => {
expect(spaceCraft.createMessage()).toEqual('Starter point Spacecraft CLI');
});
it('moves forward', () => {
expect(spaceCraft.forward(spaceCraft.y)).toEqual(1);
});
it('moves left', () => {
expect(spaceCraft.left(spaceCraft.x)).toEqual(-1);
});
it('moves right', () => {
expect(spaceCraft.right(spaceCraft.x)).toEqual(1);
});
rickithadi marked this conversation as resolved.
Show resolved Hide resolved
it('moves bacl', () => {
expect(spaceCraft.back(spaceCraft.y)).toEqual(-1);
});

});