-
Notifications
You must be signed in to change notification settings - Fork 122
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 #112 from opentable/WebInterfacePublishedDate
Added 'Updated' date field in web interface (#110)
- Loading branch information
Showing
7 changed files
with
104 additions
and
13 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
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
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
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,39 @@ | ||
'use strict'; | ||
|
||
var expect = require('chai').expect; | ||
var sinon = require('sinon'); | ||
|
||
describe('utils : dateStringify', function(){ | ||
|
||
var dateStringified = require('../../utils/date-stringify'); | ||
|
||
describe('when the date is provided', function(){ | ||
var anyValidDate = new Date(1442592664035); | ||
var dateString; | ||
|
||
before(function(){ | ||
var mockedDate = new Date(); | ||
sinon.stub(mockedDate, 'getFullYear').returns(2015); | ||
sinon.stub(mockedDate, 'getMonth').returns(8); | ||
sinon.stub(mockedDate, 'getDate').returns(18); | ||
sinon.stub(mockedDate, 'getHours').returns(17); | ||
sinon.stub(mockedDate, 'getMinutes').returns(11); | ||
sinon.stub(mockedDate, 'getSeconds').returns(4); | ||
|
||
dateString = dateStringified(mockedDate); | ||
}); | ||
|
||
it('should return the correct stringified date', function(){ | ||
expect(dateString).to.equal('2015/09/18 17:11:04'); | ||
}); | ||
}); | ||
|
||
describe('when the provided data is not valid', function(){ | ||
var anyNotValidData = 'Not a date'; | ||
var dateString = dateStringified(anyNotValidData); | ||
|
||
it('should return empty string', function(){ | ||
expect(dateString).to.be.empty; | ||
}); | ||
}); | ||
}); |
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,28 @@ | ||
'use strict'; | ||
|
||
var expect = require('chai').expect; | ||
|
||
describe('utils : padZero', function(){ | ||
|
||
var padZero = require('../../utils/pad-zero'); | ||
|
||
describe('when the correct parameters are provided', function(){ | ||
var anyData = 3; | ||
var anyValidStringLength = 5; | ||
var paddedValue = padZero(anyValidStringLength, anyData); | ||
|
||
it('should return the correct padded string', function(){ | ||
expect(paddedValue).to.equal('00003'); | ||
}); | ||
}); | ||
|
||
describe('when the provided string length is shorter/equal than the length of the data', function(){ | ||
var anyData = 3; | ||
var anyToShortStringLength = 1; | ||
var paddedValue = padZero(anyToShortStringLength, anyData); | ||
|
||
it('should return original data as a string', function(){ | ||
expect(paddedValue).to.be.equal(anyData.toString()); | ||
}); | ||
}); | ||
}); |
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,12 @@ | ||
'use strict'; | ||
|
||
var padZero = require('./pad-zero'); | ||
|
||
module.exports = function(date){ | ||
if(date instanceof Date) { | ||
return date.getFullYear() + '/' + padZero(2, date.getMonth() + 1) + '/' + padZero(2, date.getDate()) + | ||
' ' + padZero(2, date.getHours()) + ':' + padZero(2, date.getMinutes()) + ':' + padZero(2, date.getSeconds()); | ||
} | ||
|
||
return ''; | ||
}; |
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,5 @@ | ||
'use strict'; | ||
|
||
module.exports = function(length, data){ | ||
return Array(length - String(data).length + 1).join('0') + data; | ||
}; |