Posts.spec.js 642 B

12345678910111213141516171819202122232425
  1. import { shallowMount } from '@vue/test-utils'
  2. import Posts from '@/components/Home/Posts'
  3. // https://alligator.io/vuejs/testing-vue-with-jest/
  4. // https://www.synbioz.com/blog/testez_unitairement_application_vuejs_jest
  5. function mountComponentWithProps (Component, propsData) {
  6. const Constructor = Vue.extend(Component);
  7. const vm = new Constructor({
  8. propsData
  9. }).$mount();
  10. return vm.$el;
  11. }
  12. describe('Posts.vue', () => {
  13. it('posts should not be empty', () => {
  14. const PostsData = mountComponentWithProps(Posts, { all: [] });
  15. const allData = PostData.all;
  16. console.log(allData)
  17. expect(allData).toBe([])
  18. })
  19. })