Skip to content

Commit

Permalink
#100 - Add base test for AddressFields components
Browse files Browse the repository at this point in the history
  • Loading branch information
Aekal committed Aug 31, 2018
1 parent e248d84 commit eaa09ce
Show file tree
Hide file tree
Showing 2 changed files with 144 additions and 0 deletions.
59 changes: 59 additions & 0 deletions test/AddressFields.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import { shallowMount, createLocalVue } from '@vue/test-utils'
import AddressFields from '../view/frontend/web/js/components/AddressFields.vue'
import VeeValidate from 'vee-validate'

const localVue = createLocalVue()
localVue.use(VeeValidate)

describe('AddressFields.test.js', () => {
let wrapper

beforeEach(() => {
wrapper = shallowMount(AddressFields, {
propsData: {
type: 'shippingAddress'
},
computed: {
addressData: () => {
return {
city: 'Arizona',
company: 'Cafe',
country_id: {
is_region_visible: true,
label: 'United States',
value: 'US',
},
firstname: 'John',
lastname: 'Lennon',
postcode: '12312',
region: 'Arizona',
region_id: {
country_id: 'US',
label: 'Arizona',
title: 'Arizona',
value: '4'
},
street0: 'Sample Street',
street1: '2',
telephone: '123123123',
}
},
regions: () => {
return [
{
country_id: 'US',
label: 'Arizona',
title: 'Arizona',
value: '4'
}
]
}
},
localVue
})
})

it('has the expected html structure', () => {
expect(wrapper.element).toMatchSnapshot()
})
})
85 changes: 85 additions & 0 deletions test/__snapshots__/AddressFields.test.js.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`AddressFields.test.js has the expected html structure 1`] = `
<div>
<baseinput-stub />
<baseinput-stub />
<baseinput-stub />
<baseinput-stub />
<baseinput-stub />
<div
class=""
>
<label
for="country"
>
Select Country
</label>
<vue-multiselect-stub
aria-invalid="false"
aria-required="true"
data-vv-as="Country"
id="country"
label="label"
options="[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]"
placeholder="Select country"
/>
<span
class="input__message"
style="display: none;"
>
</span>
</div>
<baseinput-stub />
<baseinput-stub />
<!---->
<div
class=""
>
<label
for="region_id"
>
Select State/Province
</label>
<vue-multiselect-stub
aria-invalid="false"
aria-required="true"
data-vv-as="Region"
id="region_id"
label="label"
options="[object Object]"
placeholder="Select State/Province"
/>
<span
class="input__message"
style="display: none;"
>
</span>
</div>
<baseinput-stub />
</div>
`;

0 comments on commit eaa09ce

Please sign in to comment.