From 083b7b8e2fb86ab4459bd1a9b603eddf31f6d49f Mon Sep 17 00:00:00 2001
From: Eliot Berriot <contact@eliotberriot.com>
Date: Fri, 20 Apr 2018 18:46:18 +0200
Subject: [PATCH] Added one basic unittest for component

---
 front/test/unit/specs/components/common.spec.js | 10 ++++++++++
 front/test/unit/utils.js                        |  7 +++++++
 2 files changed, 17 insertions(+)
 create mode 100644 front/test/unit/specs/components/common.spec.js

diff --git a/front/test/unit/specs/components/common.spec.js b/front/test/unit/specs/components/common.spec.js
new file mode 100644
index 00000000..1af4144c
--- /dev/null
+++ b/front/test/unit/specs/components/common.spec.js
@@ -0,0 +1,10 @@
+import Username from '@/components/common/Username.vue'
+
+import { render } from '../../utils'
+
+describe('Username', () => {
+  it('displays username', () => {
+    const vm = render(Username, {username: 'Hello'})
+    expect(vm.$el.textContent).to.equal('Hello')
+  })
+})
diff --git a/front/test/unit/utils.js b/front/test/unit/utils.js
index 233ee982..6471fc97 100644
--- a/front/test/unit/utils.js
+++ b/front/test/unit/utils.js
@@ -1,4 +1,11 @@
 // helper for testing action with expected mutations
+import Vue from 'vue'
+
+export const render = (Component, propsData) => {
+  const Constructor = Vue.extend(Component)
+  return new Constructor({ propsData: propsData }).$mount()
+}
+
 export const testAction = ({action, payload, params, expectedMutations, expectedActions}, done) => {
   let mutationsCount = 0
   let actionsCount = 0
-- 
GitLab