Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

vue-test-utils

Package Overview
Dependencies
Maintainers
2
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vue-test-utils - npm Package Compare versions

Comparing version 1.0.0-beta.1 to 1.0.0-beta.2

201

dist/vue-test-utils.js

@@ -15,2 +15,6 @@ 'use strict';

function warn (msg) {
console.error(("[vue-test-utils]: " + msg));
}
//

@@ -392,2 +396,8 @@

WrapperArray.prototype.setComputed = function setComputed (computed) {
this.throwErrorIfWrappersIsEmpty('setComputed');
this.wrappers.forEach(function (wrapper) { return wrapper.setComputed(computed); });
};
WrapperArray.prototype.setData = function setData (data) {

@@ -496,2 +506,6 @@ this.throwErrorIfWrappersIsEmpty('setData');

ErrorWrapper.prototype.setComputed = function setComputed () {
throwError(("find did not return " + (this.selector) + ", cannot call setComputed() on empty Wrapper"));
};
ErrorWrapper.prototype.setData = function setData () {

@@ -524,2 +538,3 @@ throwError(("find did not return " + (this.selector) + ", cannot call setData() on empty Wrapper"));

this.options = options;
this.version = Number(((Vue.version.split('.')[0]) + "." + (Vue.version.split('.')[1])));
};

@@ -720,5 +735,3 @@

Wrapper.prototype.html = function html () {
var tmp = document.createElement('div');
tmp.appendChild(this.element);
return tmp.innerHTML
return this.element.outerHTML
};

@@ -753,3 +766,3 @@

Wrapper.prototype.isEmpty = function isEmpty () {
return this.vnode.children === undefined
return this.vnode.children === undefined || this.vnode.children.length === 0
};

@@ -793,4 +806,38 @@

/**
* Sets vm data
* Sets vm computed
*/
Wrapper.prototype.setComputed = function setComputed (computed) {
var this$1 = this;
if (!this.isVueComponent) {
throwError('wrapper.setComputed() can only be called on a Vue instance');
}
Object.keys(computed).forEach(function (key) {
if (this$1.version > 2.1) {
// $FlowIgnore : Problem with possibly null this.vm
if (!this$1.vm._computedWatchers[key]) {
throwError(("wrapper.setComputed() was passed a value that does not exist as a computed property on the Vue instance. Property " + key + " does not exist on the Vue instance"));
}
// $FlowIgnore : Problem with possibly null this.vm
this$1.vm._computedWatchers[key].value = computed[key];
} else {
// $FlowIgnore : Problem with possibly null this.vm
if (!this$1.vm._watchers.some(function (w) { return w.getter.name === key; })) {
throwError(("wrapper.setComputed() was passed a value that does not exist as a computed property on the Vue instance. Property " + key + " does not exist on the Vue instance"));
}
// $FlowIgnore : Problem with possibly null this.vm
this$1.vm._watchers.forEach(function (watcher) {
if (watcher.getter.name === key) {
watcher.value = computed[key];
}
});
}
});
this.update();
};
/**
* Sets vm methods
*/
Wrapper.prototype.setMethods = function setMethods (methods) {

@@ -920,2 +967,3 @@ var this$1 = this;

this._update(this._render());
this.$children.forEach(function (child) { return update.call(child); });
}

@@ -932,3 +980,7 @@

}));
// $FlowIgnore
Object.defineProperty(this, 'element', ({
get: function () { return vm.$el; },
set: function () {}
}));
this.vm = vm;

@@ -1002,2 +1054,3 @@ this.isVueComponent = true;

function addAttrs (vm, attrs) {
var originalVueConfig = Vue.config;
Vue.config.silent = true;

@@ -1009,6 +1062,7 @@ if (attrs) {

}
Vue.config.silent = false;
Vue.config.silent = originalVueConfig.silent;
}
function addListeners (vm, listeners) {
var originalVueConfig = Vue.config;
Vue.config.silent = true;

@@ -1020,3 +1074,3 @@ if (listeners) {

}
Vue.config.silent = false;
Vue.config.silent = originalVueConfig.silent;
}

@@ -1134,3 +1188,3 @@

'You can run the tests in node using jsdom + jsdom-global.\n' +
'See https://vue-test-utils.vuejs.org/en/guides/general-tips.html for more details.'
'See https://vue-test-utils.vuejs.org/en/guides/common-tips.html for more details.'
);

@@ -1208,8 +1262,135 @@ }

//
function getRealChild (vnode) {
var compOptions = vnode && vnode.componentOptions;
if (compOptions && compOptions.Ctor.options.abstract) {
return getRealChild(getFirstComponentChild(compOptions.children))
} else {
return vnode
}
}
function getFirstComponentChild (children) {
if (Array.isArray(children)) {
for (var i = 0; i < children.length; i++) {
var c = children[i];
if (c && (c.componentOptions || isAsyncPlaceholder(c))) {
return c
}
}
}
}
function isAsyncPlaceholder (node) {
return node.isComment && node.asyncFactory
}
var camelizeRE = /-(\w)/g;
var camelize = function (str) {
return str.replace(camelizeRE, function (_, c) { return c ? c.toUpperCase() : ''; })
};
function extractTransitionData (comp) {
var data = {};
var options = comp.$options;
// props
for (var key in options.propsData) {
data[key] = comp[key];
}
// events.
// extract listeners and pass them directly to the transition methods
var listeners = options._parentListeners;
for (var key$1 in listeners) {
data[camelize(key$1)] = listeners[key$1];
}
return data
}
function hasParentTransition (vnode) {
while ((vnode = vnode.parent)) {
if (vnode.data.transition) {
return true
}
}
}
var TransitionStub = {
render: function render (h) {
var children = this.$options._renderChildren;
if (!children) {
return
}
// filter out text nodes (possible whitespaces)
children = children.filter(function (c) { return c.tag || isAsyncPlaceholder(c); });
/* istanbul ignore if */
if (!children.length) {
return
}
// warn multiple elements
if (children.length > 1) {
warn(
'<transition> can only be used on a single element. Use ' +
'<transition-group> for lists.'
);
}
var mode = this.mode;
// warn invalid mode
if (mode && mode !== 'in-out' && mode !== 'out-in'
) {
warn(
'invalid <transition> mode: ' + mode
);
}
var rawChild = children[0];
// if this is a component root node and the component's
// parent container node also has transition, skip.
if (hasParentTransition(this.$vnode)) {
return rawChild
}
// apply transition data to child
// use getRealChild() to ignore abstract components e.g. keep-alive
var child = getRealChild(rawChild);
if (!child) {
return rawChild
}
(child.data || (child.data = {})).transition = extractTransitionData(this);
// mark v-show
// so that the transition module can hand over the control to the directive
if (child.data.directives && child.data.directives.some(function (d) { return d.name === 'show'; })) {
child.data.show = true;
}
return rawChild
}
};
//
var TransitionGroupStub = {
render: function render (h) {
var tag = this.tag || this.$vnode.data.tag || 'span';
var children = this.$slots.default || [];
return h(tag, null, children)
}
};
var index = {
createLocalVue: createLocalVue,
mount: mount,
shallow: shallow
shallow: shallow,
TransitionStub: TransitionStub,
TransitionGroupStub: TransitionGroupStub
};
module.exports = index;

5

package.json
{
"name": "vue-test-utils",
"version": "1.0.0-beta.1",
"version": "1.0.0-beta.2",
"description": "Utilities for testing Vue components.",

@@ -60,2 +60,5 @@ "main": "dist/vue-test-utils.js",

"gitbook-cli": "^2.3.0",
"gitbook-plugin-edit-link": "^2.0.2",
"gitbook-plugin-github": "^3.0.0",
"gitbook-plugin-theme-vuejs": "^1.1.0",
"jsdom": "^11.0.0",

@@ -62,0 +65,0 @@ "jsdom-global": "^3.0.2",

@@ -6,3 +6,7 @@ # vue-test-utils

```
npm install --save-dev vue-test-utils@1.0.0-beta
// npm
npm install --save-dev vue-test-utils@1.0.0-beta.1
// yarn
yarn add --dev vue-test-utils@1.0.0-beta.1
```

@@ -20,4 +24,4 @@

- [example with Jest](https://github.com/eddyerburgh/vue-test-utils-jest-example)
- [example with Mocha](https://github.com/eddyerburgh/vue-test-utils-mocha-example)
- [example with Jest](https://github.com/vuejs/vue-test-utils-jest-example)
- [example with Mocha](https://github.com/vuejs/vue-test-utils-mocha-webpack-example)
- [example with tape](https://github.com/eddyerburgh/vue-test-utils-tape-example)

@@ -24,0 +28,0 @@ - [example with AVA](https://github.com/eddyerburgh/vue-test-utils-ava-example)

@@ -46,2 +46,3 @@ import Vue, { VNodeData, Component, ComponentOptions, FunctionalComponentOptions } from 'vue'

update (): void
setComputed (computed: object): void
setData (data: object): void

@@ -48,0 +49,0 @@ setMethods (data: object): void

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc