Fix client tests

This commit is contained in:
Pavel Djundik 2019-11-21 11:11:06 +02:00
parent 0ac9601a3a
commit 49dc6ffd8f
15 changed files with 42 additions and 32 deletions

View file

@ -15,6 +15,7 @@
import throttle from "lodash/throttle";
import constants from "../js/constants";
import storage from "../js/localStorage";
import {generateUserContextMenu} from "../js/helpers/contextMenu";
import Sidebar from "./Sidebar.vue";
import ImageViewer from "./ImageViewer.vue";
@ -92,6 +93,23 @@ export default {
// TODO: maybe move this method to the store or some other more accessible place
this.$refs.contextMenu.open(event, items);
},
openContextMenuForMentionedNick(event, network, nick) {
// TODO: Find a better way to do this
const channel = this.$store.state.activeChannel.channel;
let user = channel.users.find((u) => u.nick === nick);
if (!user) {
user = {
nick: nick,
mode: "",
};
}
const items = generateUserContextMenu(this.$root, channel, network, user);
this.openContextMenu(event, items);
},
},
};
</script>

View file

@ -106,7 +106,7 @@ export default {
isAction() {
return typeof MessageTypes["message-" + this.message.type] !== "undefined";
},
openUserContextMenu($event, user) {
openUserContextMenu(event, user) {
const items = generateUserContextMenu(this.$root, this.channel, this.network, user);
this.$root.$refs.app.openContextMenu(event, items);
},

View file

@ -11,8 +11,6 @@ import emojiMap from "./fullnamemap.json";
import LinkPreviewToggle from "../../components/LinkPreviewToggle.vue";
import LinkPreviewFileSize from "../../components/LinkPreviewFileSize.vue";
import InlineChannel from "../../components/InlineChannel.vue";
import store from "../store";
import {generateUserContextMenu} from "./contextMenu";
const emojiModifiersRegex = /[\u{1f3fb}-\u{1f3ff}]/gu;
@ -182,6 +180,11 @@ function parse(createElement, text, message = undefined, network = undefined, $r
fragments
);
} else if (textPart.nick) {
// TODO: This really does not belong here, find a better way
const openContextMenu = (event) => {
$root.$refs.app.openContextMenuForMentionedNick(event, network, textPart.nick);
};
return createElement(
"span",
{
@ -192,21 +195,8 @@ function parse(createElement, text, message = undefined, network = undefined, $r
"data-name": textPart.nick,
},
on: {
contextmenu($event) {
$event.preventDefault();
const channel = store.state.activeChannel.channel;
let user = channel.users.find((u) => u.nick === textPart.nick);
if (!user) {
user = {
nick: textPart.nick,
mode: "",
};
}
const items = generateUserContextMenu($root, channel, network, user);
$root.$refs.app.openContextMenu($event, items);
},
contextmenu: openContextMenu,
click: openContextMenu,
},
},
fragments

View file

@ -2,9 +2,9 @@
const expect = require("chai").expect;
const stub = require("sinon").stub;
const Auth = require("../../../client/js/auth");
const localStorage = require("../../../client/js/localStorage");
const location = require("../../../client/js/location");
const Auth = require("../../../client/js/auth").default;
const localStorage = require("../../../client/js/localStorage").default;
const location = require("../../../client/js/location").default;
describe("Auth", function() {
describe(".signout", function() {

View file

@ -1,7 +1,7 @@
"use strict";
const expect = require("chai").expect;
const constants = require("../../../client/js/constants");
const constants = require("../../../client/js/constants").default;
describe("client-side constants", function() {
describe(".colorCodeMap", function() {

View file

@ -1,7 +1,7 @@
"use strict";
const expect = require("chai").expect;
const friendlysize = require("../../../../client/js/helpers/friendlysize");
const friendlysize = require("../../../../client/js/helpers/friendlysize").default;
describe("friendlysize helper", function() {
it("should render big values in human-readable version", function() {

View file

@ -1,7 +1,8 @@
"use strict";
const expect = require("chai").expect;
const anyIntersection = require("../../../../../client/js/helpers/ircmessageparser/anyIntersection");
const anyIntersection = require("../../../../../client/js/helpers/ircmessageparser/anyIntersection")
.default;
describe("anyIntersection", () => {
it("should not intersect on edges", () => {

View file

@ -1,7 +1,7 @@
"use strict";
const expect = require("chai").expect;
const fill = require("../../../../../client/js/helpers/ircmessageparser/fill");
const fill = require("../../../../../client/js/helpers/ircmessageparser/fill").default;
describe("fill", () => {
const text = "01234567890123456789";

View file

@ -1,7 +1,8 @@
"use strict";
const expect = require("chai").expect;
const findChannels = require("../../../../../client/js/helpers/ircmessageparser/findChannels");
const findChannels = require("../../../../../client/js/helpers/ircmessageparser/findChannels")
.default;
describe("findChannels", () => {
it("should find single letter channel", () => {

View file

@ -1,7 +1,7 @@
"use strict";
const expect = require("chai").expect;
const findEmoji = require("../../../../../client/js/helpers/ircmessageparser/findEmoji");
const findEmoji = require("../../../../../client/js/helpers/ircmessageparser/findEmoji").default;
describe("findEmoji", () => {
it("should find default emoji presentation character", () => {

View file

@ -1,7 +1,7 @@
"use strict";
const expect = require("chai").expect;
const findNames = require("../../../../../client/js/helpers/ircmessageparser/findNames");
const findNames = require("../../../../../client/js/helpers/ircmessageparser/findNames").default;
describe("findNames", () => {
it("should find nicks in text", () => {

View file

@ -1,7 +1,7 @@
"use strict";
const expect = require("chai").expect;
const merge = require("../../../../../client/js/helpers/ircmessageparser/merge");
const merge = require("../../../../../client/js/helpers/ircmessageparser/merge").default;
describe("merge", () => {
it("should split style information", () => {

View file

@ -1,7 +1,7 @@
"use strict";
const expect = require("chai").expect;
const parseStyle = require("../../../../../client/js/helpers/ircmessageparser/parseStyle");
const parseStyle = require("../../../../../client/js/helpers/ircmessageparser/parseStyle").default;
describe("parseStyle", () => {
it("should skip control codes", () => {

View file

@ -1,7 +1,7 @@
"use strict";
const expect = require("chai").expect;
const localetime = require("../../../../client/js/helpers/localetime");
const localetime = require("../../../../client/js/helpers/localetime").default;
describe("localetime helper", () => {
it("should render a human-readable date", () => {

View file

@ -1,7 +1,7 @@
"use strict";
const expect = require("chai").expect;
const roundBadgeNumber = require("../../../../client/js/helpers/roundBadgeNumber");
const roundBadgeNumber = require("../../../../client/js/helpers/roundBadgeNumber").default;
describe("roundBadgeNumber helper", function() {
it("should return any number under 1000 as a string", function() {