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

Slava's frontend api challenge (incomplete) #118

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
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
Prev Previous commit
Next Next commit
class ChitterModel and tests
  • Loading branch information
amfibiya17 committed Jun 5, 2022
commit d03b78eebc253909bbb48bba5e64bde10df22bb2
1 change: 1 addition & 0 deletions apiChitter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = ApiChitter;
1 change: 1 addition & 0 deletions apiChitter.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
const ApiChitter = require('./apiChitter');
19 changes: 19 additions & 0 deletions chitterModel.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
class ChitterModel {
constructor() {
this.peeps = [];
}

getPeeps() {
return this.peeps;
}

addPeep(peep) {
this.peeps.push(peep);
}

setPeeps(peeps) {
this.peeps = peeps;
}
}

module.exports = ChitterModel;
25 changes: 25 additions & 0 deletions chitterModel.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
const ChitterModel = require('./chitterModel');

describe('ChitterModel', () => {
let model;

beforeEach(() => {
model = new ChitterModel();
});

it('returns a list of peeps', () => {
expect(model.getPeeps()).toEqual([]);
});

it('adds a peep to peeps list', () => {
model.addPeep('first peep');

expect(model.getPeeps()).toEqual(['first peep']);
});

it('sets peeps from peeps list', () => {
model.setPeeps(['first peep', 'second peep']);

expect(model.getPeeps()).toEqual(['first peep', 'second peep']);
});
});
1 change: 1 addition & 0 deletions chitterView.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = ChitterView;
1 change: 1 addition & 0 deletions chitterView.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
const ChitterView = require('./chitterView');
9 changes: 9 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
const ApiChitter = require('./apiChitter');
const ChitterModel = require('./chitterModel');
const ChitterView = require('./chitterView');

const api = new ApiChitter();
const model = new ChitterModel();
const view = new ChitterView(model, api);

console.log('Hello!');