|
| 1 | +'use babel' |
| 2 | + |
| 3 | +import {minutesToMilliseconds} from '../lib/time-helpers' |
| 4 | +import ThemeFlux from '../lib/theme-flux' |
| 5 | + |
| 6 | +describe('ThemeFlux', () => { |
| 7 | + beforeEach(() => { |
| 8 | + spyOn(Date, "now") |
| 9 | + window.setInterval = window.fakeSetInterval |
| 10 | + }) |
| 11 | + |
| 12 | + it('changes the theme to dark at night, and to light during the day', () => { |
| 13 | + atom.config.set('core.themes', ['', '']) |
| 14 | + Date.now.andReturn(new Date(1994, 4, 22, 23).getTime()) |
| 15 | + ThemeFlux.activate() |
| 16 | + expect(atom.config.get('core.themes')).toEqual(['one-dark-ui', 'one-dark-syntax']) |
| 17 | + |
| 18 | + Date.now.andReturn(new Date(1994, 4, 22, 10).getTime()) |
| 19 | + advanceClock(minutesToMilliseconds(ThemeFlux.getCheckIntervalInMinutes())) |
| 20 | + expect(atom.config.get('core.themes')).toEqual(['one-light-ui', 'one-light-syntax']) |
| 21 | + |
| 22 | + Date.now.andReturn(new Date(1994, 4, 22, 18).getTime()) |
| 23 | + advanceClock(minutesToMilliseconds(ThemeFlux.getCheckIntervalInMinutes())) |
| 24 | + expect(atom.config.get('core.themes')).toEqual(['one-dark-ui', 'one-dark-syntax']) |
| 25 | + |
| 26 | + Date.now.andReturn(new Date(1994, 4, 23, 5).getTime()) |
| 27 | + advanceClock(minutesToMilliseconds(ThemeFlux.getCheckIntervalInMinutes())) |
| 28 | + expect(atom.config.get('core.themes')).toEqual(['one-dark-ui', 'one-dark-syntax']) |
| 29 | + |
| 30 | + Date.now.andReturn(new Date(1994, 4, 23, 7).getTime()) |
| 31 | + advanceClock(minutesToMilliseconds(ThemeFlux.getCheckIntervalInMinutes())) |
| 32 | + expect(atom.config.get('core.themes')).toEqual(['one-light-ui', 'one-light-syntax']) |
| 33 | + }) |
| 34 | +}) |
0 commit comments