openingTimesRFC/__tests__/index.test.js

47 lines
1.6 KiB
JavaScript

const openingTimes = require('../index.js')
describe('calculating opening times', () => {
it('is early morning, waiting in front of the door', () => {
const date = new Date(2017, 1, 23, 6, 0, 0, 0)
const resultStr = openingTimes(date)
expect(resultStr).toBe('öffnet in 01:00')
})
it('is early morning, waiting in front of the door, hoping someone opens early', () => {
const date = new Date(2017, 1, 23, 6, 58, 59, 0)
const resultStr = openingTimes(date)
expect(resultStr).toBe('öffnet in 00:01')
})
it('is sunday...', () => {
const date = new Date(2017, 1, 19, 16, 0, 0, 0)
const resultStr = openingTimes(date)
expect(resultStr).toBe('zur zeit geschlossen, öffnet wieder in 15:00')
})
it('is late night friday', () => {
const date = new Date(2017, 1, 18, 23, 30, 0, 0)
const resultStr = openingTimes(date)
expect(resultStr).toBe('zur zeit geschlossen, öffnet wieder in 31:30')
})
it('should open in 9 h', () => {
const date = new Date(2017, 1, 22, 22, 0, 0, 0)
const resultStr = openingTimes(date)
expect(resultStr).toBe('zur zeit geschlossen, öffnet wieder in 09:00')
})
it('is opened', () => {
const date = new Date(2017, 1, 22, 14, 5, 0, 0)
const resultStr = openingTimes(date)
expect(resultStr).toBe('noch 05:55 geöffnet')
})
it('is still opened, but hurry up', () => {
const date = new Date(2017, 1, 22, 19, 59, 55, 0)
const resultStr = openingTimes(date)
expect(resultStr).toBe('noch 00:00 geöffnet')
})
})