Skip to content

Commit

Permalink
Fix lint & tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ItsOnlyBinary committed Nov 22, 2024
1 parent b310e81 commit 52f6aa9
Show file tree
Hide file tree
Showing 10 changed files with 32 additions and 26 deletions.
4 changes: 2 additions & 2 deletions build/plugins/webpack/import-icons.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,15 +166,15 @@ function writeIfChanged(file, _data) {
fs.writeFileSync(file, data);
}

function getFiles(sourceDir) {
function getFiles(src) {
const files = [];

const readDir = (dirPath) => fs.readdirSync(dirPath).forEach((name) => {
const entry = path.join(dirPath, name);
fs.lstatSync(entry).isDirectory() ? readDir(entry) : files.push(entry);
});

readDir(sourceDir);
readDir(src);

return files.filter(
(file) => (fileRegex.test(file) && file !== outputFile)
Expand Down
4 changes: 3 additions & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@ module.exports = {
'^.+\\.vue$': require.resolve('@vue/vue3-jest'),
'^.+\\.jsx?$': require.resolve('babel-jest'),
},
transformIgnorePatterns: ['/node_modules/'],
transformIgnorePatterns: ['/node_modules/(?!(ip-regex)/)'],
moduleNameMapper: {
'^@/(.*)$': '<rootDir>/src/$1',
'\\.(jpg|ico|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$': '<rootDir>/tests/mocks/fileMock.js',
'\\.(css|less)$': '<rootDir>/tests/mocks/fileMock.js',
},
testMatch: [
'**/tests/unit/**/*.spec.[jt]s?(x)',
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
"dev": "node build/commands/dev.js",
"build": "node build/commands/build.js",
"stats": "node build/commands/build.js --stats",
"lint": "npm-run-all lint:*",
"lint": "npm-run-all \"lint:*\"",
"lint:js": "eslint --ext .js,.vue ./",
"lint:style": "stylelint \"./src/**/*.vue\" \"./src/**/*.scss\"",
"lint:style": "stylelint --allow-empty-input \"./src/**/*.{vue,html,css,less,scss,sass}\"",
"test": "jest",
"gendocs": "rm -rf srcdocs/ && jsdoc -c jsdoc.json"
},
Expand Down Expand Up @@ -52,7 +52,7 @@
"@stylistic/stylelint-plugin": "^2.1.3",
"@vue/compiler-sfc": "^3.5.13",
"@vue/eslint-config-airbnb": "^7.0.1",
"@vue/vue3-jest": "^29.2.6",
"@vue/vue3-jest": "29",
"autoprefixer": "^10.4.20",
"babel-jest": "^29.7.0",
"babel-loader": "^9.2.1",
Expand Down
2 changes: 1 addition & 1 deletion src/components/Container.vue
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
<server-view :network="network" />
</template>
<template v-else>
<message-list :buffer="buffer" :key="buffer.id" />
<message-list :key="buffer.id" :buffer="buffer" />
<sidebar
v-if="!buffer.isSpecial()"
:network="network"
Expand Down
4 changes: 2 additions & 2 deletions src/components/MessageList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ export default {
},
},
mounted() {
console.log('mounted');
// console.log('mounted');
if (!this.showMessages) {
setTimeout(() => {
this.showMessages = true;
Expand Down Expand Up @@ -304,7 +304,7 @@ export default {
});
},
updated() {
console.log('updated');
// console.log('updated');
if (this.showMessages && this.showOverlay) {
setTimeout(() => {
this.showOverlay = false;
Expand Down
2 changes: 1 addition & 1 deletion src/components/UserBox.vue
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@
<script>
'kiwi public';
import * as ipRegex from 'ip-regex';
import ipRegex from 'ip-regex';
import * as TextFormatting from '@/helpers/TextFormatting';
import * as IrcdDiffs from '@/helpers/IrcdDiffs';
import * as Misc from '@/helpers/Misc';
Expand Down
Empty file added tests/mocks/fileMock.js
Empty file.
2 changes: 1 addition & 1 deletion tests/unit/NetworkState.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ describe('NetworkState', () => {
expect(network).toBeInstanceOf(NetworkState);
expect(network.name).toBe('TestNetwork');
expect(network.connection.nick).toBe('TestNick');
expect(network.appState).toBe(s);
expect(network.appState).toEqual(s);
});

it('should add a NetworkState to the global state', () => {
Expand Down
30 changes: 17 additions & 13 deletions tests/unit/StartupError.spec.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
import Vue from 'vue';
import { createApp } from 'vue';
import StartupError from '@/components/StartupError';

Vue.mixin({
computed: {
$t() {
return (key, options) => key;
},
},
});

describe('StartupError.vue', () => {
it('should render correct contents', () => {
const vm = new Vue({
el: document.createElement('div'),
render: (h) => h(StartupError, { props: { error: 'some error' } }),
const app = createApp(
StartupError,
{ error: 'some error' }
);

app.mixin({
computed: {
$t() {
return (key, options) => key;
},
},
});
expect(vm.$el.querySelector('span.kiwi-error-text').textContent).toEqual('some error');

const el = document.createElement('div');
app.mount(el);

expect(el.querySelector('span.kiwi-error-text').textContent).toEqual('some error');
});
});
4 changes: 2 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2833,7 +2833,7 @@ __metadata:
languageName: node
linkType: hard

"@vue/vue3-jest@npm:^29.2.6":
"@vue/vue3-jest@npm:29":
version: 29.2.6
resolution: "@vue/vue3-jest@npm:29.2.6"
dependencies:
Expand Down Expand Up @@ -8569,7 +8569,7 @@ __metadata:
"@stylistic/stylelint-plugin": "npm:^2.1.3"
"@vue/compiler-sfc": "npm:^3.5.13"
"@vue/eslint-config-airbnb": "npm:^7.0.1"
"@vue/vue3-jest": "npm:^29.2.6"
"@vue/vue3-jest": "npm:29"
autoprefixer: "npm:^10.4.20"
babel-jest: "npm:^29.7.0"
babel-loader: "npm:^9.2.1"
Expand Down

0 comments on commit 52f6aa9

Please sign in to comment.