Remove tests, fix lint, update packages

This commit is contained in:
Pavel Djundik 2018-09-12 21:09:43 +03:00
parent cc895e67ee
commit dd686b563d
3 changed files with 6 additions and 49 deletions

View File

@ -18,6 +18,11 @@ export default {
props: { props: {
message: Object, message: Object,
}, },
computed: {
localeDate() {
return moment(this.message.time).format("D MMMM YYYY");
},
},
mounted() { mounted() {
if (this.hoursPassed() < 48) { if (this.hoursPassed() < 48) {
this.$root.$on("daychange", this.dayChange); this.$root.$on("daychange", this.dayChange);
@ -26,14 +31,9 @@ export default {
beforeDestroy() { beforeDestroy() {
this.$root.$off("daychange", this.dayChange); this.$root.$off("daychange", this.dayChange);
}, },
computed: {
localeDate() {
return moment(this.message.time).format("D MMMM YYYY");
},
},
methods: { methods: {
hoursPassed() { hoursPassed() {
return moment.duration(moment().diff(moment(this.message.time))).asHours() return moment.duration(moment().diff(moment(this.message.time))).asHours();
}, },
dayChange() { dayChange() {
this.$forceUpdate(); this.$forceUpdate();

View File

@ -1,24 +0,0 @@
"use strict";
const expect = require("chai").expect;
const moment = require("moment");
const friendlydate = require("../../../../../client/js/libs/handlebars/friendlydate");
describe("friendlydate Handlebars helper", () => {
it("should render 'Today' as a human-friendly date", () => {
const time = new Date().getTime();
expect(friendlydate(time)).to.equal("Today");
});
it("should render 'Yesterday' as a human-friendly date", () => {
const time = new Date().getTime() - 24 * 3600 * 1000;
expect(friendlydate(time)).to.equal("Yesterday");
});
it("should not render any friendly dates prior to the day before", () => {
[2, 7, 30, 365, 1000].forEach((day) => {
const time = new Date().getTime() - 24 * 3600 * 1000 * day;
expect(friendlydate(time)).to.equal(moment(time).format("D MMMM YYYY"));
});
});
});

View File

@ -1,19 +0,0 @@
"use strict";
const expect = require("chai").expect;
const localedate = require("../../../../../client/js/libs/handlebars/localedate");
describe("localedate Handlebars helper", function() {
it("should render a human-readable date", function() {
// 12PM in UTC time
const date = new Date("2014-05-22T12:00:00Z");
// Offset between UTC and local timezone
const offset = date.getTimezoneOffset() * 60 * 1000;
// Pretend local timezone is UTC by moving the clock of that offset
const time = date.getTime() + offset;
expect(localedate(time)).to.equal("22 May 2014");
});
});