forked from makersacademy/news-summary-challenge
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnewsModel.test.js
37 lines (34 loc) · 992 Bytes
/
newsModel.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
const Model = require('./newsModel');
describe("NewsModel", () => {
it("gets news articles from the model", () => {
const model = new Model;
expect(model.getArticles()).toStrictEqual([])
});
it("sets news articles into the model", () => {
const model = new Model;
const articles = {
response: {
results: [
{ headline: "Story 1" },
{ headline: "Story 2" }
]
}}
model.setArticles(articles);
expect(model.getArticles().length).toBe(2)
expect(model.getArticles()[0].headline).toBe('Story 1')
});
it("resets news articles in the model after some had been loaded", () => {
const model = new Model;
const articles = {
response: {
results: [
{ headline: "Story 1" },
{ headline: "Story 2" }
]
}}
model.setArticles(articles);
expect(model.getArticles().length).toBe(2)
model.reset();
expect(model.getArticles().length).toBe(0)
});
});