-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from odranoelBR/develop
Develop
- Loading branch information
Showing
5 changed files
with
73 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
import { mountQuasar } from '../index' | ||
import axios from 'axios' | ||
import SelectApi from '@components/SelectApi.vue' | ||
import response from './response.json' | ||
|
||
jest.mock('axios'); | ||
|
||
|
@@ -19,8 +18,8 @@ beforeEach(() => { | |
const defaultPropsData = () => ({ http: axios, api: '' }) | ||
|
||
let returnData = [ | ||
{ id: 1, first_name: 'Brominator', email: '[email protected]' }, | ||
{ id: 2, first_name: 'Foo f', email: '[email protected]' } | ||
{ id: 1, first_name: 'Brominator' }, | ||
{ id: 2, first_name: 'Foo f' } | ||
] | ||
|
||
test('mount component with request', async () => { | ||
|
@@ -118,3 +117,54 @@ test('get $emit errorOnGet event', async () => { | |
|
||
expect(wrapper.emitted().errorOnGet).toBeTruthy() | ||
}) | ||
|
||
test('nested api response', async () => { | ||
|
||
axios.get.mockResolvedValueOnce({ | ||
data: { | ||
people: [], | ||
cars: { | ||
data: returnData | ||
} | ||
} | ||
}); | ||
|
||
const props = defaultPropsData() | ||
props.optionFormater = (list) => { | ||
return list.cars.data | ||
} | ||
|
||
const wrapper = await mountQuasar(SelectApi, { | ||
propsData: props | ||
}) | ||
|
||
expect(wrapper.vm.clearOptions).toHaveLength(2) | ||
expect(wrapper.vm.options).toHaveLength(2) | ||
expect(wrapper.vm.clearOptions[0]['first_name']).toBe('Brominator') | ||
}) | ||
|
||
test('filtering the list', async () => { | ||
|
||
axios.get.mockResolvedValueOnce({ data: returnData }) | ||
|
||
const props = defaultPropsData() | ||
props.filter = true | ||
props.useInput = true | ||
props.optionValue = 'id' | ||
props.optionLabel = 'first_name' | ||
|
||
const wrapper = await mountQuasar(SelectApi, { | ||
propsData: props | ||
}) | ||
|
||
expect(wrapper.vm.clearOptions).toHaveLength(2) | ||
expect(wrapper.vm.options).toHaveLength(2) | ||
expect(wrapper.vm.qListeners.filter).toBeTruthy() | ||
expect(wrapper.emitted().filter).toBeFalsy() | ||
|
||
wrapper.vm.filterHandler('Bro', (fn) => fn()) | ||
|
||
|
||
expect(wrapper.vm.clearOptions).toHaveLength(2) | ||
expect(wrapper.vm.options).toHaveLength(1) | ||
}) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters