├── .gitignore ├── package.json ├── src └── Notification.js └── test ├── helpers └── setup-browser-env.js └── notification.js /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "vue-testing", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "keywords": [], 10 | "author": "", 11 | "license": "ISC", 12 | "babel": { 13 | "presets": [ 14 | "es2015" 15 | ] 16 | }, 17 | "ava": { 18 | "require": [ 19 | "babel-register", 20 | "./test/helpers/setup-browser-env.js" 21 | ] 22 | }, 23 | "devDependencies": { 24 | "ava": "^0.18.1", 25 | "babel-register": "^6.22.0", 26 | "browser-env": "^2.0.21" 27 | }, 28 | "dependencies": { 29 | "vue": "^2.1.10" 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/Notification.js: -------------------------------------------------------------------------------- 1 | export default { 2 | template: '

{{ notification }}

', 3 | 4 | props: ['message'], 5 | 6 | computed: { 7 | notification() { 8 | return this.message.toUpperCase(); 9 | } 10 | } 11 | }; 12 | -------------------------------------------------------------------------------- /test/helpers/setup-browser-env.js: -------------------------------------------------------------------------------- 1 | import browserEnv from 'browser-env'; 2 | 3 | browserEnv(); -------------------------------------------------------------------------------- /test/notification.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue/dist/vue.js'; 2 | import test from 'ava'; 3 | import Notification from '../src/Notification'; 4 | 5 | let vm; 6 | 7 | test.beforeEach(t => { 8 | let N = Vue.extend(Notification); 9 | 10 | vm = new N({ propsData: { 11 | message: 'Foobar' 12 | }}).$mount(); 13 | }); 14 | 15 | 16 | test('that it renders a notification', t => { 17 | t.is(vm.$el.textContent, 'FOOBAR'); 18 | }); 19 | 20 | 21 | // test('that it computes the notification', t => { 22 | // t.is(vm.notification, 'FOOBAR'); 23 | // }); 24 | --------------------------------------------------------------------------------