Include tests

This commit is contained in:
mickie 2021-08-18 20:16:30 -05:00
parent aa0f0ee70d
commit 0104b27bbe
2 changed files with 35 additions and 121 deletions

View File

@ -1,25 +1,25 @@
// import sinon from 'sinon';
// import { App } from '../lib/app';
// import * as Dom from '../lib/dom';
import sinon from 'sinon';
import { App } from '../lib/app';
import * as Dom from '../lib/dom';
// describe('testing App', () => {
// let sandboxes;
// let renderDateTime;
describe('testing App', () => {
let sandboxes;
let renderItems;
// beforeEach(() => {
// sandboxes = sinon.createSandbox();
// renderDateTime = sandboxes.stub(Dom, 'renderDateTime');
// });
beforeEach(() => {
sandboxes = sinon.createSandbox();
renderItems = sandboxes.stub(Dom, 'renderItems');
});
// afterEach(() => {
// sandboxes.restore();
// });
afterEach(() => {
sandboxes.restore();
});
// describe('testing App', () => {
// it('should return Thu Nov 19 23:00', () => {
// const app = new App();
// app.render();
// expect(renderDateTime.called).toBeTruthy();
// });
// });
// });
describe('testing App', () => {
it('app is rendered', () => {
const app = new App();
app.render();
expect(renderItems.called).toBeTruthy();
});
});
});

View File

@ -1,101 +1,15 @@
// import sinon from 'sinon';
// import { getDisplayDateTime, getPeriod, getPalette } from '../lib/utils';
import sinon from 'sinon';
import { generateArray } from '../lib/utils';
import * as instance from '../lib/instances';
// describe('testing utils', () => {
// let sandboxes;
// beforeEach(() => {
// sandboxes = sinon.createSandbox();
// sandboxes.useFakeTimers({
// now: new Date(2020, 10, 19, 23, 0),
// });
// });
// afterEach(() => {
// sandboxes.restore();
// });
// describe('testing getDisplayDateTime', () => {
// it('should return Thu Nov 19 23:00', () => {
// const actual = getDisplayDateTime();
// const expected = { date: 'Thu Nov 19', time: '23:00', period: 'night' };
// expect(actual).toEqual(expected);
// });
// it('should return Thu Nov 19 01:00', () => {
// sinon.useFakeTimers({
// now: new Date(2020, 10, 19, 1, 0),
// });
// const actual = getDisplayDateTime();
// const expected = { date: 'Thu Nov 19', time: '01:00', period: 'night' };
// expect(actual).toEqual(expected);
// });
// it('should return Thu Nov 19 23:23', () => {
// sinon.useFakeTimers({
// now: new Date(2020, 10, 19, 23, 23),
// });
// const actual = getDisplayDateTime();
// const expected = { date: 'Thu Nov 19', time: '23:23', period: 'night' };
// expect(actual).toEqual(expected);
// });
// });
// describe('testing getPeriod', () => {
// it('should return morning - 05:00 AM', () => {
// const actual = getPeriod(new Date(2020, 10, 19, 5, 0));
// const expected = 'morning';
// expect(actual).toEqual(expected);
// });
// it('should return morning - 11:59 AM', () => {
// const actual = getPeriod(new Date(2020, 10, 19, 11, 59));
// const expected = 'morning';
// expect(actual).toEqual(expected);
// });
// it('should return afternoon - 12:00 PM', () => {
// const actual = getPeriod(new Date(2020, 10, 19, 12, 0));
// const expected = 'afternoon';
// expect(actual).toEqual(expected);
// });
// it('should return afternoon - 04:59 PM', () => {
// const actual = getPeriod(new Date(2020, 10, 19, 16, 59));
// const expected = 'afternoon';
// expect(actual).toEqual(expected);
// });
// it('should return night - 05:00 PM', () => {
// const actual = getPeriod(new Date(2020, 10, 19, 17, 0));
// const expected = 'night';
// expect(actual).toEqual(expected);
// });
// it('should return night - 04:59 AM', () => {
// const actual = getPeriod(new Date(2020, 10, 19, 4, 59));
// const expected = 'night';
// expect(actual).toEqual(expected);
// });
// });
// describe('testing getPalette', () => {
// it('should return morning color code - #282e54', () => {
// const actual = getPalette('morning');
// const expected = '#282e54';
// expect(actual).toEqual(expected);
// });
// it('should return afternoon color code - #000000', () => {
// const actual = getPalette('afternoon');
// const expected = '#000000';
// expect(actual).toEqual(expected);
// });
// it('should return morning color code - #ffdd91', () => {
// const actual = getPalette('night');
// const expected = '#ffdd91';
// expect(actual).toEqual(expected);
// });
// });
// });
describe('testing utils', () => {
describe('testing generateArray', () => {
it('should return an array of instances', () => {
const actual = generateArray(instance);
const testInstances = actual.slice(1, 3); // Friendica and GNUsocial
const expected = [instance.friendica, instance.gnusocial];
expect(testInstances).toEqual(expected);
});
});
// TODO include the rest
});