pad.pub0.org/tests/frontend/specs/timeslider_labels.js

65 lines
2.0 KiB
JavaScript
Raw Normal View History

Low hanging lint frontend tests (#4695) * lint: low hanging specs/alphabet.js * lint: low hanging specs/authorship_of_editions.js * lint: low hanging specs/bold.js * lint: low hanging specs/caret.js * lint: low hanging specs/change_user_color.js * lint: low hanging specs/change_user_name.js * lint: low hanging specs/chat.js * lint: low hanging specs/chat_load_messages.js * lint: low hanging specs/clear_authorship_colors.js * lint: low hanging specs/delete.js * lint: low hanging specs/drag_and_drop.js * lint: low hanging specs/embed_value.js * lint: low hanging specs/enter.js * lint: low hanging specs/font_type.js * lint: low hanging specs/helper.js * lint: low hanging specs/importexport.js * lint: low hanging specs/importindents.js * lint: low hanging specs/indentation.js * lint: low hanging specs/italic.js * lint: low hanging specs/language.js * lint: low hanging specs/multiple_authors_clear_authorship_colors.js * lint: low hanging specs/ordered_list.js * lint: low hanging specs/pad_modal.js * lint: low hanging specs/redo.js * lint: low hanging specs/responsiveness.js * lint: low hanging specs/select_formatting_buttons.js * lint: low hanging specs/strikethrough.js * lint: low hanging specs/timeslider.js * lint: low hanging specs/timeslider_labels.js * lint: low hanging specs/timeslider_numeric_padID.js * lint: low hanging specs/timeslider_revisions.js * lint: low hanging specs/undo.js * lint: low hanging specs/unordered_list.js * lint: low hanging specs/xxauto_reconnect.js * lint: attempt to do remote_runner.js * lint: helper linting * lint: rate limit linting * use constructor for Event to make eslint happier * for squash: lint fix refinements * for squash: lint fix refinements Co-authored-by: Richard Hansen <rhansen@rhansen.org>
2021-02-01 20:23:14 +00:00
'use strict';
describe('timeslider', function () {
// create a new pad before each test run
beforeEach(function (cb) {
2013-02-06 23:28:46 +00:00
helper.newPad(cb);
});
/**
* @todo test authorsList
*/
Low hanging lint frontend tests (#4695) * lint: low hanging specs/alphabet.js * lint: low hanging specs/authorship_of_editions.js * lint: low hanging specs/bold.js * lint: low hanging specs/caret.js * lint: low hanging specs/change_user_color.js * lint: low hanging specs/change_user_name.js * lint: low hanging specs/chat.js * lint: low hanging specs/chat_load_messages.js * lint: low hanging specs/clear_authorship_colors.js * lint: low hanging specs/delete.js * lint: low hanging specs/drag_and_drop.js * lint: low hanging specs/embed_value.js * lint: low hanging specs/enter.js * lint: low hanging specs/font_type.js * lint: low hanging specs/helper.js * lint: low hanging specs/importexport.js * lint: low hanging specs/importindents.js * lint: low hanging specs/indentation.js * lint: low hanging specs/italic.js * lint: low hanging specs/language.js * lint: low hanging specs/multiple_authors_clear_authorship_colors.js * lint: low hanging specs/ordered_list.js * lint: low hanging specs/pad_modal.js * lint: low hanging specs/redo.js * lint: low hanging specs/responsiveness.js * lint: low hanging specs/select_formatting_buttons.js * lint: low hanging specs/strikethrough.js * lint: low hanging specs/timeslider.js * lint: low hanging specs/timeslider_labels.js * lint: low hanging specs/timeslider_numeric_padID.js * lint: low hanging specs/timeslider_revisions.js * lint: low hanging specs/undo.js * lint: low hanging specs/unordered_list.js * lint: low hanging specs/xxauto_reconnect.js * lint: attempt to do remote_runner.js * lint: helper linting * lint: rate limit linting * use constructor for Event to make eslint happier * for squash: lint fix refinements * for squash: lint fix refinements Co-authored-by: Richard Hansen <rhansen@rhansen.org>
2021-02-01 20:23:14 +00:00
it("Shows a date/time in the timeslider and make sure it doesn't include NaN", async function () {
// make some changes to produce 3 revisions
const revs = 3;
for (let i = 0; i < revs; i++) {
await helper.edit('a\n');
2013-02-06 23:28:46 +00:00
}
await helper.gotoTimeslider(revs);
await helper.waitForPromise(() => helper.contentWindow().location.hash === `#${revs}`);
// the datetime of last edit
const timerTimeLast = new Date(helper.timesliderTimerTime()).getTime();
// the day of this revision, e.g. August 12, 2020 (stripped the string "Saved")
const dateLast = new Date(helper.revisionDateElem().substr(6)).getTime();
// the label/revision, ie Version 3
const labelLast = helper.revisionLabelElem().text();
// the datetime should be a date
expect(Number.isNaN(timerTimeLast)).to.eql(false);
// the Date object of the day should not be NaN
expect(Number.isNaN(dateLast)).to.eql(false);
// the label should be Version `Number`
expect(labelLast).to.be(`Version ${revs}`);
// Click somewhere left on the timeslider to go to revision 0
helper.sliderClick(1);
// the datetime of last edit
const timerTime = new Date(helper.timesliderTimerTime()).getTime();
// the day of this revision, e.g. August 12, 2020
const date = new Date(helper.revisionDateElem().substr(6)).getTime();
// the label/revision, e.g. Version 0
const label = helper.revisionLabelElem().text();
// the datetime should be a date
expect(Number.isNaN(timerTime)).to.eql(false);
// the last revision should be newer or have the same time
expect(timerTimeLast).to.not.be.lessThan(timerTime);
// the Date object of the day should not be NaN
expect(Number.isNaN(date)).to.eql(false);
// the label should be Version 0
expect(label).to.be('Version 0');
2013-02-06 23:28:46 +00:00
});
});