@@ -385,9 +518,15 @@ async function changeState(value) {
- {{ t('ticket.summary.created') }}
- {{ t('ticket.summary.package') }}
- {{ t('ticket.summary.quantity') }}
+ {{
+ t('ticket.summary.created')
+ }}
+ {{
+ t('ticket.summary.package')
+ }}
+ {{
+ t('ticket.summary.quantity')
+ }}
@@ -409,11 +548,21 @@ async function changeState(value) {
- {{ t('ticket.summary.quantity') }}
- {{ t('ticket.summary.description') }}
- {{ t('ticket.summary.price') }}
- {{ t('ticket.summary.taxClass') }}
- {{ t('ticket.summary.amount') }}
+ {{
+ t('ticket.summary.quantity')
+ }}
+ {{
+ t('ticket.summary.description')
+ }}
+ {{
+ t('ticket.summary.price')
+ }}
+ {{
+ t('ticket.summary.taxClass')
+ }}
+ {{
+ t('ticket.summary.amount')
+ }}
@@ -422,7 +571,11 @@ async function changeState(value) {
{{ props.row.description }}
{{ toCurrency(props.row.price) }}
{{ props.row.taxClass.description }}
- {{ toCurrency(props.row.quantity * props.row.price) }}
+ {{
+ toCurrency(
+ props.row.quantity * props.row.price
+ )
+ }}
@@ -439,13 +592,27 @@ async function changeState(value) {
- {{ t('ticket.summary.description') }}
- {{ t('ticket.summary.created') }}
- {{ t('ticket.summary.requester') }}
- {{ t('ticket.summary.atender') }}
- {{ t('ticket.summary.quantity') }}
- {{ t('ticket.summary.price') }}
- {{ t('ticket.summary.item') }}
+ {{
+ t('ticket.summary.description')
+ }}
+ {{
+ t('ticket.summary.created')
+ }}
+ {{
+ t('ticket.summary.requester')
+ }}
+ {{
+ t('ticket.summary.atender')
+ }}
+ {{
+ t('ticket.summary.quantity')
+ }}
+ {{
+ t('ticket.summary.price')
+ }}
+ {{
+ t('ticket.summary.item')
+ }}
Ok
@@ -458,8 +625,14 @@ async function changeState(value) {
{{ props.row.quantity }}
{{ toCurrency(props.row.price) }}
-
- {{ props.row.sale.itemFk }}
-
+ {{
+ props.row.sale.itemFk
+ }}
+
diff --git a/test/vitest/__tests__/App.spec.js b/test/vitest/__tests__/App.spec.js
deleted file mode 100644
index c04962c58..000000000
--- a/test/vitest/__tests__/App.spec.js
+++ /dev/null
@@ -1,84 +0,0 @@
-import { vi, describe, expect, it, beforeAll } from 'vitest';
-import { createWrapper } from 'app/test/vitest/helper';
-import App from 'src/App.vue';
-import { useSession } from 'src/composables/useSession';
-
-const mockLoggedIn = vi.fn();
-const mockDestroy = vi.fn();
-const session = useSession();
-
-vi.mock('src/composables/useSession', () => ({
- useSession: () => ({
- isLoggedIn: mockLoggedIn,
- destroy: mockDestroy,
- }),
-}));
-
-describe.skip('App', () => {
- let vm;
-
- beforeAll(() => {
- const options = {
- global: {
- stubs: ['router-view'],
- },
- };
- vm = createWrapper(App, options).vm;
- });
-
- it('should return a login error message', async () => {
- vi.spyOn(vm.quasar, 'notify');
-
- session.isLoggedIn.mockReturnValue(false);
-
- const response = {
- response: {
- status: 401,
- data: {
- error: {
- message: 'Invalid username or password',
- },
- },
- },
- };
-
- expect(vm.onResponseError(response)).rejects.toEqual(
- expect.objectContaining(response)
- );
- expect(vm.quasar.notify).toHaveBeenCalledWith(
- expect.objectContaining({
- message: 'Invalid username or password',
- type: 'negative',
- })
- );
- });
-
- it('should return an unauthorized error message', async () => {
- vi.spyOn(vm.quasar, 'notify');
-
- session.isLoggedIn.mockReturnValue(true);
-
- const response = {
- response: {
- status: 401,
- data: {
- error: {
- message: 'Access denied',
- },
- },
- },
- };
-
- expect(vm.responseError(response)).rejects.toEqual(
- expect.objectContaining(response)
- );
- expect(vm.quasar.notify).toHaveBeenCalledWith(
- expect.objectContaining({
- message: 'Access denied',
- type: 'negative',
- })
- );
-
- expect(session.destroy).toHaveBeenCalled();
- });
-});
diff --git a/test/vitest/__tests__/boot/axios.spec.js b/test/vitest/__tests__/boot/axios.spec.js
new file mode 100644
index 000000000..a95c57fba
--- /dev/null
+++ b/test/vitest/__tests__/boot/axios.spec.js
@@ -0,0 +1,81 @@
+import { vi, describe, expect, it } from 'vitest';
+import { onRequest, onResponseError } from 'src/boot/axios';
+import { Notify } from 'quasar'
+
+vi.mock('src/composables/useSession', () => ({
+ useSession: () => ({
+ getToken: () => 'DEFAULT_TOKEN'
+ }),
+}));
+
+vi.mock('src/router', () => ({}));
+
+describe('Axios boot', () => {
+
+ describe('onRequest()', async () => {
+ it('should set the "Authorization" property on the headers', async () => {
+ const config = { headers: {} };
+
+ const resultConfig = onRequest(config);
+
+ expect(resultConfig).toEqual(expect.objectContaining({
+ headers: {
+ Authorization: 'DEFAULT_TOKEN'
+ }
+ }));
+ });
+ })
+
+ describe('onResponseError()', async () => {
+ it('should call to the Notify plugin with a message error for an status code "500"', async () => {
+ Notify.create = vi.fn()
+
+ const error = {
+ response: {
+ status: 500
+ }
+ };
+
+ const result = onResponseError(error);
+
+
+ expect(result).rejects.toEqual(
+ expect.objectContaining(error)
+ );
+ expect(Notify.create).toHaveBeenCalledWith(
+ expect.objectContaining({
+ message: 'An internal server error has ocurred',
+ type: 'negative',
+ })
+ );
+ });
+
+ it('should call to the Notify plugin with a message from the response property', async () => {
+ Notify.create = vi.fn()
+
+ const error = {
+ response: {
+ status: 401,
+ data: {
+ error: {
+ message: 'Invalid user or password'
+ }
+ }
+ }
+ };
+
+ const result = onResponseError(error);
+
+
+ expect(result).rejects.toEqual(
+ expect.objectContaining(error)
+ );
+ expect(Notify.create).toHaveBeenCalledWith(
+ expect.objectContaining({
+ message: 'Invalid user or password',
+ type: 'negative',
+ })
+ );
+ });
+ })
+});
diff --git a/test/vitest/__tests__/pages/Login/Login.spec.js b/test/vitest/__tests__/pages/Login/Login.spec.js
index fff021144..fadfc898f 100644
--- a/test/vitest/__tests__/pages/Login/Login.spec.js
+++ b/test/vitest/__tests__/pages/Login/Login.spec.js
@@ -1,7 +1,6 @@
import { vi, describe, expect, it, beforeAll, afterEach } from 'vitest';
import { createWrapper, axios } from 'app/test/vitest/helper';
import Login from 'pages/Login/LoginMain.vue';
-import { Notify } from 'quasar';
describe('Login', () => {
let vm;