mirror of
https://github.com/orangecoding/fredy.git
synced 2026-06-16 12:31:07 +00:00
38 lines
1.3 KiB
JavaScript
38 lines
1.3 KiB
JavaScript
import utils from '../../lib/utils.js';
|
|
import assert from 'assert';
|
|
import { expect } from 'chai';
|
|
|
|
const fakeWorkingHoursConfig = (from, to) => ({
|
|
workingHours: {
|
|
to,
|
|
from,
|
|
},
|
|
});
|
|
describe('utils', () => {
|
|
describe('#isOneOf()', () => {
|
|
it('should be false', () => {
|
|
assert.equal(utils.isOneOf('bla', ['blub']), false);
|
|
});
|
|
it('should be true', () => {
|
|
assert.equal(utils.isOneOf('bla blub blubber', ['bla']), true);
|
|
});
|
|
});
|
|
describe('#duringWorkingHoursOrNotSet()', () => {
|
|
it('should be false', () => {
|
|
expect(utils.duringWorkingHoursOrNotSet(fakeWorkingHoursConfig('12:00', '13:00'), 0)).to.be.false;
|
|
});
|
|
it('should be true', () => {
|
|
expect(utils.duringWorkingHoursOrNotSet(fakeWorkingHoursConfig('10:00', '16:00'), 1622026740000)).to.be.true;
|
|
});
|
|
it('should be true if nothing set', () => {
|
|
expect(utils.duringWorkingHoursOrNotSet(fakeWorkingHoursConfig(null, null), 1622026740000)).to.be.true;
|
|
});
|
|
it('should be true if only to is set', () => {
|
|
expect(utils.duringWorkingHoursOrNotSet(fakeWorkingHoursConfig(null, '13:00'), 1622026740000)).to.be.true;
|
|
});
|
|
it('should be true if only from is set', () => {
|
|
expect(utils.duringWorkingHoursOrNotSet(fakeWorkingHoursConfig('12:00', null), 1622026740000)).to.be.true;
|
|
});
|
|
});
|
|
});
|