2 |
3 |
Hello, {{ name }}!
4 |
5 |
6 |
7 |
26 |
27 |
32 |
--------------------------------------------------------------------------------
/test/index.test.js:
--------------------------------------------------------------------------------
1 | /* eslint-disable no-underscore-dangle */
2 | import _ from 'lodash';
3 | import Vue from 'vue';
4 | import test from 'ava';
5 | import TestComponentFromNodePath from 'test.vue'; // eslint-disable-line
6 | import TestComponent from './test.vue';
7 |
8 | test('has loaded NODE_PATH', (t) => {
9 | t.true(_.isFunction(TestComponentFromNodePath.created));
10 | });
11 |
12 | test('has a created hook', (t) => {
13 | t.true(_.isFunction(TestComponent.created));
14 | });
15 |
16 | test('sets default data', (t) => {
17 | t.true(_.isFunction(TestComponent.data));
18 | t.deepEqual(TestComponent.data(), { name: 'Test' });
19 | });
20 |
21 | test('renders the correct message', async (t) => {
22 | const Constructor = Vue.extend(TestComponent);
23 | const vm = new Constructor().$mount();
24 | t.is(vm.$el.querySelector('h1').textContent, 'Hello, World!');
25 | // Update
26 | vm.setName('Foo');
27 | await Vue.nextTick();
28 | t.is(vm.$el.querySelector('h1').textContent, 'Hello, Foo!');
29 | // Update directly 👻
30 | vm._data.name = 'Bar';
31 | await Vue.nextTick();
32 | t.is(vm.$el.querySelector('h1').textContent, 'Hello, Bar!');
33 | });
34 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2017 Kenneth Powers