Žert testování Vuetify v-img

0

Otázka

Mám složku, ve které chci vyzkoušet velikost v-img je nastaven, pro život mě nemůžu přijít na to, co na háček. Snažil jsem se chytil span tag, který obklopuje kód a pak dělá > div se ten div, že dostane generované vuetify tak, že jsem pak mohou získat atribut style a zkontrolujte velikost je nastavena správně, ale nezdá se, že chtějí dělat to, když jsem se přidat .délka se to vrátí 0, pokaždé.

Můj Vue složky (zápatí.vue)

    <template>
      <span class="footerImagesLayout">
        <v-img 
         :height="easg_logo_height"
         :src="$store.state.app.easg_logo.src"
         :width="easg_logo_width"
        contain
         />
     <v-img 
         :height="oma_logo_height"
         :src="$store.state.app.oma_logo.src"
         :width="oma_logo_width"
        contain
         />
       </div>
    </template>
<script>
   export default {
      data(){
         easg_logo_width: this.$store.state.app.easg_logo.top.width, 
         easg_logo_height: this.$store.state.app.easg_logo.top.height,
         oma_logo_width: this.$store.state.app.oma_logo.top.width,
         oma_logo_width: this.$store.state.app.oma_logo.top.width,
      }
   }
</script>

Můj test (footer.test.js)

import {shallowMount, createLocalVue} from '@vue/test-utils'
import Vuex from 'vuex';
import Footer from '@components/layouts/default/footer'
import Vuetify from 'vuetify';

const vuetify = new Vuetify();
const localVue = createLocalVue();
localVue.use(Vuex);

describe("Footer tests", ()=> {
  let wrapper;
  let store;
  let state;


beforeEach(() => {
   state= {
     app: {
        easg_logo:{
           src: "~/assets/images/easg.jpg",
           text: "EASG", 
           top:{
             height: 72,
             width: 82
           }
         },
    oma_logo:{
           src: "~/assets/images/oma.jpg",
           text: "OMA", 
           top:{
             height: 72,
             width: 82
           }
         }
      }
}

store = new Vuex.Store({
            modules:{
               state
            }
     })

})

test('store test', ()=> {
   wrapper = shallowMount(Footer, {store, localVue, vuetify})
   console.log(wrapper.findAll('.footerImagesLayout > div').length) // this returns 0
   const a = 'a'
    expect(a).toBe('a')
});

});
jestjs nuxt.js vue.js vuejs2
2021-11-22 14:06:50
1

Nejlepší odpověď

1

Pravděpodobně budete chtít připojit místo shallowMount, protože v-img není vykreslen, ale narazil s shallowMount.

Z dokumentace: "Jako mount, (shallowMount) vytváří Obal, který obsahuje montáž a tavené Vue složkou, ale narazil dítě součástí."

2021-11-22 14:44:56

V jiných jazycích

Tato stránka je v jiných jazycích

Русский
..................................................................................................................
Italiano
..................................................................................................................
Polski
..................................................................................................................
Română
..................................................................................................................
한국어
..................................................................................................................
हिन्दी
..................................................................................................................
Français
..................................................................................................................
Türk
..................................................................................................................
Português
..................................................................................................................
ไทย
..................................................................................................................
中文
..................................................................................................................
Español
..................................................................................................................
Slovenský
..................................................................................................................