updated intentation for the files in test directory

This commit is contained in:
Carlos Jimenez Ruiz 2022-03-11 11:39:56 +01:00
parent 5ccc0f6aa8
commit ad717cd2eb
8 changed files with 73 additions and 70 deletions

View File

@ -24,5 +24,8 @@
}, },
"[javascript]": { "[javascript]": {
"editor.defaultFormatter": "vscode.typescript-language-features" "editor.defaultFormatter": "vscode.typescript-language-features"
},
"[vue]": {
"editor.defaultFormatter": "johnsoncodehk.volar"
} }
} }

View File

@ -1,10 +1,10 @@
module.exports = { module.exports = {
extends: [ extends: [
// Removes 'no-undef' lint errors for Jest global functions (`describe`, `it`, etc), // Removes 'no-undef' lint errors for Jest global functions (`describe`, `it`, etc),
// add Jest-specific lint rules and Jest plugin // add Jest-specific lint rules and Jest plugin
// See https://github.com/jest-community/eslint-plugin-jest#recommended // See https://github.com/jest-community/eslint-plugin-jest#recommended
'plugin:jest/recommended', 'plugin:jest/recommended',
// Uncomment following line to apply style rules // Uncomment following line to apply style rules
// 'plugin:jest/style', // 'plugin:jest/style',
], ],
}; };

View File

@ -8,34 +8,34 @@ import MyButton from './demo/MyButton';
installQuasarPlugin(); installQuasarPlugin();
describe('MyButton', () => { describe('MyButton', () => {
it('has increment method', () => { it('has increment method', () => {
const wrapper = mount(MyButton); const wrapper = mount(MyButton);
const { vm } = wrapper; const { vm } = wrapper;
expect(typeof vm.increment).toBe('function'); expect(typeof vm.increment).toBe('function');
}); });
it('can check the inner text content', () => { it('can check the inner text content', () => {
const wrapper = mount(MyButton); const wrapper = mount(MyButton);
const { vm } = wrapper; const { vm } = wrapper;
expect((vm.$el as HTMLElement).textContent).toContain('rocket muffin'); expect((vm.$el as HTMLElement).textContent).toContain('rocket muffin');
expect(wrapper.find('.content').text()).toContain('rocket muffin'); expect(wrapper.find('.content').text()).toContain('rocket muffin');
}); });
it('sets the correct default data', () => { it('sets the correct default data', () => {
const wrapper = mount(MyButton); const wrapper = mount(MyButton);
const { vm } = wrapper; const { vm } = wrapper;
expect(typeof vm.counter).toBe('number'); expect(typeof vm.counter).toBe('number');
expect(vm.counter).toBe(0); expect(vm.counter).toBe(0);
}); });
it('correctly updates counter when button is pressed', async () => { it('correctly updates counter when button is pressed', async () => {
const wrapper = shallowMount(MyButton); const wrapper = shallowMount(MyButton);
const { vm } = wrapper; const { vm } = wrapper;
const button = wrapper.findComponent(QBtn); const button = wrapper.findComponent(QBtn);
await button.trigger('click'); await button.trigger('click');
expect(vm.counter).toBe(1); expect(vm.counter).toBe(1);
}); });
}); });

View File

@ -6,13 +6,13 @@ import MyDialog from './demo/MyDialog';
installQuasarPlugin(); installQuasarPlugin();
describe('MyDialog', () => { describe('MyDialog', () => {
it('should mount MyDialog', () => { it('should mount MyDialog', () => {
const wrapper = mount(MyDialog, { const wrapper = mount(MyDialog, {
data: () => ({ data: () => ({
isDialogOpen: true, isDialogOpen: true,
}), }),
}); });
expect(wrapper.exists()).toBe(true); expect(wrapper.exists()).toBe(true);
}); });
}); });

View File

@ -1,20 +1,20 @@
import { defineComponent, ref } from 'vue'; import { defineComponent, ref } from 'vue';
export default defineComponent({ export default defineComponent({
name: 'MyButton', name: 'MyButton',
props: { props: {
incrementStep: { incrementStep: {
type: Number, type: Number,
default: 1, default: 1,
},
}, },
}, setup(props) {
setup(props) { const counter = ref(0);
const counter = ref(0); const input = ref('rocket muffin');
const input = ref('rocket muffin'); function increment() {
function increment() { counter.value += props.incrementStep;
counter.value += props.incrementStep; }
}
return { counter, input, increment }; return { counter, input, increment };
}, },
}); });

View File

@ -1,9 +1,9 @@
<script lang="ts" src="./MyButton.ts"></script> <script lang="ts" src="./MyButton.ts"></script>
<template> <template>
<div> <div>
<p class="content">{{ input }}</p> <p class="content">{{ input }}</p>
<span>{{ counter }}</span> <span>{{ counter }}</span>
<q-btn class="button" @click="increment()"></q-btn> <q-btn class="button" @click="increment()"></q-btn>
</div> </div>
</template> </template>

View File

@ -1,10 +1,10 @@
import { defineComponent } from 'vue'; import { defineComponent } from 'vue';
export default defineComponent({ export default defineComponent({
name: 'MyDialog', name: 'MyDialog',
data() { data() {
return { return {
isDialogOpen: false, isDialogOpen: false,
}; };
}, },
}); });

View File

@ -1,9 +1,9 @@
<script lang="ts" src="./MyDialog.ts"></script> <script lang="ts" src="./MyDialog.ts"></script>
<template> <template>
<q-dialog v-model="isDialogOpen"> <q-dialog v-model="isDialogOpen">
<q-card> <q-card>
<q-card-section>Custom dialog which should be tested</q-card-section> <q-card-section>Custom dialog which should be tested</q-card-section>
</q-card> </q-card>
</q-dialog> </q-dialog>
</template> </template>