-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16 from akhilome/ch-dummy-data-160239312
#160239312 Create Dummy Data
- Loading branch information
Showing
5 changed files
with
113 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
const orders = [ | ||
{ | ||
id: 1, | ||
author: 'Michelle Graham', | ||
title: 'Shrimps', | ||
date: '2018-05-20', | ||
status: 'pending', | ||
}, | ||
{ | ||
id: 2, | ||
author: 'Chrisette Clark', | ||
title: 'Chicken & Chips', | ||
date: '2018-05-21', | ||
status: 'pending', | ||
}, | ||
{ | ||
id: 3, | ||
author: 'Jamiu Rafa', | ||
title: 'Shrimps', | ||
date: '2018-06-01', | ||
status: 'pending', | ||
}, | ||
{ | ||
id: 4, | ||
author: 'Tomal Gardner', | ||
title: 'Spiced Turkey', | ||
date: '2018-06-04', | ||
status: 'pending', | ||
}, | ||
]; | ||
|
||
export default orders; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import todaysDate from '../utils/date'; | ||
|
||
class Order { | ||
constructor(id, author, food) { | ||
this.id = id; | ||
this.author = author; | ||
this.title = food; | ||
this.status = 'pending'; | ||
this.date = todaysDate(); | ||
} | ||
} | ||
|
||
export default Order; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
function makeTodaysDate() { | ||
const now = new Date(Date.now()); | ||
const [year, month, day] = [ | ||
now.getFullYear(), | ||
now.getMonth(), | ||
now.getDay(), | ||
]; | ||
|
||
const padding = (num) => { | ||
const padded = num > 10 ? `${num}` : `0${num}`; | ||
return padded; | ||
}; | ||
|
||
return `${year}-${padding(month)}-${padding(day)}`; | ||
} | ||
|
||
export default makeTodaysDate; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import chai from 'chai'; | ||
import 'chai/register-should'; | ||
import dirtyChai from 'dirty-chai'; | ||
import Order from '../../server/models/Order'; | ||
import todaysDate from '../../server/utils/date'; | ||
|
||
chai.use(dirtyChai); | ||
|
||
describe('New order model', () => { | ||
const order = new Order(1, 'Kizito Akhilome', 'Egg & Bread'); | ||
|
||
it('should return a non-empty object', () => { | ||
order.should.be.an('object').that.is.not.empty(); | ||
}); | ||
|
||
it('should contain all the necessary properties', () => { | ||
order.should.have.all.keys('id', 'author', 'title', 'status', 'date'); | ||
}); | ||
|
||
it('should contain the correct data', () => { | ||
order.id.should.be.a('number').that.is.equal(1); | ||
order.author.should.equal('Kizito Akhilome'); | ||
order.title.should.equal('Egg & Bread'); | ||
order.status.should.equal('pending'); | ||
order.date.should.equals(todaysDate()); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import chai from 'chai'; | ||
import 'chai/register-should'; | ||
import dirtyChai from 'dirty-chai'; | ||
import makeTodaysDate from '../../server/utils/date'; | ||
|
||
chai.use(dirtyChai); | ||
|
||
describe('Today\'s Date Utility Function', () => { | ||
it('should be a function', () => { | ||
makeTodaysDate.should.be.a('function'); | ||
}); | ||
|
||
it('should return a non-empty string', () => { | ||
makeTodaysDate().should.be.a('string').which.is.not.empty(); | ||
}); | ||
|
||
it('should return today\'s date', () => { | ||
const today = new Date(Date.now()); | ||
makeTodaysDate().should.be.a('string').that.has.a.lengthOf('YYYY-MM-DD'.length); | ||
makeTodaysDate().should.be.a('string').which.includes(today.getDay()); | ||
makeTodaysDate().should.be.a('string').which.includes(today.getMonth()); | ||
makeTodaysDate().should.be.a('string').which.includes(today.getFullYear()); | ||
}); | ||
}); |