Posts.spec.js 567 B

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