mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-18 15:17:25 +01:00
lint unit tests for client
This commit is contained in:
@@ -9,11 +9,13 @@ module.exports = {
|
|||||||
rules: {
|
rules: {
|
||||||
'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'off',
|
'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'off',
|
||||||
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
|
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
|
||||||
|
// TODO find a way to let eslint understand webpack aliases
|
||||||
'import/no-unresolved': 'off',
|
'import/no-unresolved': 'off',
|
||||||
'vue/no-v-html': 'off',
|
'vue/no-v-html': 'off',
|
||||||
'vue/html-self-closing': ['error', {
|
'vue/html-self-closing': ['error', {
|
||||||
html: {
|
html: {
|
||||||
void: 'never',
|
void: 'never',
|
||||||
|
// Otherwise it results in self closing span(s) and div(s)
|
||||||
normal: 'never',
|
normal: 'never',
|
||||||
component: 'always',
|
component: 'always',
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<div class="col-md-6 offset-3">
|
<div class="col-md-6 offset-3">
|
||||||
<h1>{{ $t('clearBrowserData') }}</h1>
|
<h1>{{ $t('clearBrowserData') }}</h1>
|
||||||
<p v-html="$t('localStorageTryFirst', localStorageTryFirst) "></p>
|
<p v-html="$t('localStorageTryFirst', localStorageTryFirst) "></p>
|
||||||
<br >
|
<br>
|
||||||
<p class="text-center">
|
<p class="text-center">
|
||||||
<button
|
<button
|
||||||
class="btn btn-lg btn-danger"
|
class="btn btn-lg btn-danger"
|
||||||
@@ -12,10 +12,10 @@
|
|||||||
:popover="$t('localStorageClearExplanation')"
|
:popover="$t('localStorageClearExplanation')"
|
||||||
@click="clearLocalStorage()"
|
@click="clearLocalStorage()"
|
||||||
>
|
>
|
||||||
{{ $t('localStorageClear') }}
|
{{ $t('localStorageClear') }}
|
||||||
</button>
|
</button>
|
||||||
</p>
|
</p>
|
||||||
<br >
|
<br>
|
||||||
<p v-html="$t('localStorageTryNext', localStorageTryNext) "></p>
|
<p v-html="$t('localStorageTryNext', localStorageTryNext) "></p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1 +1,6 @@
|
|||||||
module.exports = require('../../../../test/.eslintrc.js');
|
const base = require('../../../../test/.eslintrc.js');
|
||||||
|
|
||||||
|
// TODO find a way to let eslint understand webpack aliases
|
||||||
|
base.rules['import/no-unresolved'] = 'off';
|
||||||
|
|
||||||
|
module.exports = base;
|
||||||
|
|||||||
@@ -64,7 +64,8 @@ describe('Notifications', () => {
|
|||||||
|
|
||||||
const userExpBefore = 10;
|
const userExpBefore = 10;
|
||||||
const userExpAfter = 12;
|
const userExpAfter = 12;
|
||||||
wrapper.vm.displayUserExpAndLvlNotifications(userExpAfter, userExpBefore, userLevel, userLevel);
|
wrapper.vm
|
||||||
|
.displayUserExpAndLvlNotifications(userExpAfter, userExpBefore, userLevel, userLevel);
|
||||||
|
|
||||||
expect(expSpy).to.be.calledWith(userExpAfter - userExpBefore);
|
expect(expSpy).to.be.calledWith(userExpAfter - userExpBefore);
|
||||||
expSpy.restore();
|
expSpy.restore();
|
||||||
@@ -80,7 +81,10 @@ describe('Notifications', () => {
|
|||||||
const expEarned = 5;
|
const expEarned = 5;
|
||||||
const userExpBefore = toNextLevel(userLevelBefore) - expEarned;
|
const userExpBefore = toNextLevel(userLevelBefore) - expEarned;
|
||||||
const userExpAfter = 0;
|
const userExpAfter = 0;
|
||||||
wrapper.vm.displayUserExpAndLvlNotifications(userExpAfter, userExpBefore, userLevelAfter, userLevelBefore);
|
wrapper.vm
|
||||||
|
.displayUserExpAndLvlNotifications(
|
||||||
|
userExpAfter, userExpBefore, userLevelAfter, userLevelBefore,
|
||||||
|
);
|
||||||
|
|
||||||
expect(expSpy).to.be.calledWith(expEarned);
|
expect(expSpy).to.be.calledWith(expEarned);
|
||||||
expSpy.restore();
|
expSpy.restore();
|
||||||
@@ -97,7 +101,9 @@ describe('Notifications', () => {
|
|||||||
const expNeeded = 5;
|
const expNeeded = 5;
|
||||||
const userExpBefore = toNextLevel(userLevelBefore) - expNeeded;
|
const userExpBefore = toNextLevel(userLevelBefore) - expNeeded;
|
||||||
const userExpAfter = 5;
|
const userExpAfter = 5;
|
||||||
wrapper.vm.displayUserExpAndLvlNotifications(userExpAfter, userExpBefore, userLevelAfter, userLevelBefore);
|
wrapper.vm.displayUserExpAndLvlNotifications(
|
||||||
|
userExpAfter, userExpBefore, userLevelAfter, userLevelBefore,
|
||||||
|
);
|
||||||
|
|
||||||
expect(expSpy).to.be.calledWith(expEarned);
|
expect(expSpy).to.be.calledWith(expEarned);
|
||||||
expSpy.restore();
|
expSpy.restore();
|
||||||
@@ -114,7 +120,9 @@ describe('Notifications', () => {
|
|||||||
const expNeeded = -5;
|
const expNeeded = -5;
|
||||||
const userExpBefore = toNextLevel(userLevelBefore) - expNeeded;
|
const userExpBefore = toNextLevel(userLevelBefore) - expNeeded;
|
||||||
const userExpAfter = 15;
|
const userExpAfter = 15;
|
||||||
wrapper.vm.displayUserExpAndLvlNotifications(userExpAfter, userExpBefore, userLevelAfter, userLevelBefore);
|
wrapper.vm.displayUserExpAndLvlNotifications(
|
||||||
|
userExpAfter, userExpBefore, userLevelAfter, userLevelBefore,
|
||||||
|
);
|
||||||
|
|
||||||
expect(expSpy).to.be.calledWith(expEarned);
|
expect(expSpy).to.be.calledWith(expEarned);
|
||||||
expSpy.restore();
|
expSpy.restore();
|
||||||
@@ -131,7 +139,9 @@ describe('Notifications', () => {
|
|||||||
const expNeeded = 5;
|
const expNeeded = 5;
|
||||||
const userExpBefore = toNextLevel(userLevelBefore) - expNeeded;
|
const userExpBefore = toNextLevel(userLevelBefore) - expNeeded;
|
||||||
const userExpAfter = 5;
|
const userExpAfter = 5;
|
||||||
wrapper.vm.displayUserExpAndLvlNotifications(userExpAfter, userExpBefore, userLevelAfter, userLevelBefore);
|
wrapper.vm.displayUserExpAndLvlNotifications(
|
||||||
|
userExpAfter, userExpBefore, userLevelAfter, userLevelBefore,
|
||||||
|
);
|
||||||
|
|
||||||
expect(expSpy).to.be.calledWith(expEarned);
|
expect(expSpy).to.be.calledWith(expEarned);
|
||||||
expSpy.restore();
|
expSpy.restore();
|
||||||
@@ -145,7 +155,9 @@ describe('Notifications', () => {
|
|||||||
|
|
||||||
const userExpBefore = 10;
|
const userExpBefore = 10;
|
||||||
const userExpAfter = 5;
|
const userExpAfter = 5;
|
||||||
wrapper.vm.displayUserExpAndLvlNotifications(userExpAfter, userExpBefore, userLevel, userLevel);
|
wrapper.vm.displayUserExpAndLvlNotifications(
|
||||||
|
userExpAfter, userExpBefore, userLevel, userLevel,
|
||||||
|
);
|
||||||
|
|
||||||
expect(expSpy).to.be.calledWith(userExpAfter - userExpBefore);
|
expect(expSpy).to.be.calledWith(userExpAfter - userExpBefore);
|
||||||
expSpy.restore();
|
expSpy.restore();
|
||||||
@@ -159,7 +171,9 @@ describe('Notifications', () => {
|
|||||||
|
|
||||||
const userExpBefore = 5;
|
const userExpBefore = 5;
|
||||||
const userExpAfter = -3;
|
const userExpAfter = -3;
|
||||||
wrapper.vm.displayUserExpAndLvlNotifications(userExpAfter, userExpBefore, userLevel, userLevel);
|
wrapper.vm.displayUserExpAndLvlNotifications(
|
||||||
|
userExpAfter, userExpBefore, userLevel, userLevel,
|
||||||
|
);
|
||||||
|
|
||||||
expect(expSpy).to.be.calledWith(userExpAfter - userExpBefore);
|
expect(expSpy).to.be.calledWith(userExpAfter - userExpBefore);
|
||||||
expSpy.restore();
|
expSpy.restore();
|
||||||
@@ -175,7 +189,9 @@ describe('Notifications', () => {
|
|||||||
const expEarned = -20;
|
const expEarned = -20;
|
||||||
const userExpBefore = 20;
|
const userExpBefore = 20;
|
||||||
const userExpAfter = 0;
|
const userExpAfter = 0;
|
||||||
wrapper.vm.displayUserExpAndLvlNotifications(userExpAfter, userExpBefore, userLevelAfter, userLevelBefore);
|
wrapper.vm.displayUserExpAndLvlNotifications(
|
||||||
|
userExpAfter, userExpBefore, userLevelAfter, userLevelBefore,
|
||||||
|
);
|
||||||
|
|
||||||
expect(expSpy).to.be.calledWith(expEarned);
|
expect(expSpy).to.be.calledWith(expEarned);
|
||||||
expSpy.restore();
|
expSpy.restore();
|
||||||
|
|||||||
@@ -140,17 +140,17 @@ describe('Store', () => {
|
|||||||
data: {
|
data: {
|
||||||
title: 'internal',
|
title: 'internal',
|
||||||
},
|
},
|
||||||
|
created () {
|
||||||
|
expect(this.getName('123')).to.deep.equal(['test', '123']);
|
||||||
|
expect(this.getNameRenamed('123')).to.deep.equal(['test', '123']);
|
||||||
|
done();
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
...mapActions(['getName']),
|
...mapActions(['getName']),
|
||||||
...mapActions({
|
...mapActions({
|
||||||
getNameRenamed: 'getName',
|
getNameRenamed: 'getName',
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
created () {
|
|
||||||
expect(this.getName('123')).to.deep.equal(['test', '123']);
|
|
||||||
expect(this.getNameRenamed('123')).to.deep.equal(['test', '123']);
|
|
||||||
done();
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import {
|
|||||||
getTypeLabel,
|
getTypeLabel,
|
||||||
getFilterLabels,
|
getFilterLabels,
|
||||||
getActiveFilter,
|
getActiveFilter,
|
||||||
} from '@/libs/store/helpers/filterTasks.js';
|
} from '@/libs/store/helpers/filterTasks';
|
||||||
|
|
||||||
describe('Filter Category for Tasks', () => {
|
describe('Filter Category for Tasks', () => {
|
||||||
describe('getTypeLabel', () => {
|
describe('getTypeLabel', () => {
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import shuffle from 'lodash/shuffle';
|
|||||||
import {
|
import {
|
||||||
orderSingleTypeTasks,
|
orderSingleTypeTasks,
|
||||||
// orderMultipleTypeTasks,
|
// orderMultipleTypeTasks,
|
||||||
} from '@/libs/store/helpers/orderTasks.js';
|
} from '@/libs/store/helpers/orderTasks';
|
||||||
|
|
||||||
|
|
||||||
describe('Task Order Helper Function', () => {
|
describe('Task Order Helper Function', () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user