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

ospec

Package Overview
Dependencies
Maintainers
1
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ospec - npm Package Compare versions

Comparing version 1.0.0 to 1.1.0

9

ospec.js

@@ -22,3 +22,3 @@ "use strict"

o.only = function(subject, predicate) {o(subject, only = predicate)}
o.spy = function() {
o.spy = function(fn) {
var spy = function() {

@@ -28,3 +28,10 @@ spy.this = this

spy.callCount++
if (fn) return fn.apply(this, arguments)
}
if (fn)
Object.defineProperties(spy, {
length: {value: fn.length},
name: {value: fn.name}
})
spy.args = []

@@ -31,0 +38,0 @@ spy.callCount = 0

6

package.json
{
"name": "ospec",
"version": "1.0.0",
"version": "1.1.0",
"description": "Noiseless testing framework",

@@ -11,3 +11,5 @@ "main": "ospec.js",

"author": "Leo Horie <lhorie@hotmail.com>",
"license": "MIT"
"license": "MIT",
"bin": "./bin/ospec",
"repository": "lhorie/mithril.js#rewrite"
}

@@ -7,3 +7,3 @@ # ospec

Version: 1.0
Version: 1.1
License: MIT

@@ -121,2 +121,25 @@

A spy can also wrap other functions, like a decorator:
```javascript
//code to be tested
var count = 0
function inc() {
count++
}
//test suite
var o = require("ospec")
o.spec("call()", function() {
o("works", function() {
var spy = o.spy(inc)
spy()
o(count).equals(1)
})
})
```
### Asynchronous tests

@@ -341,3 +364,3 @@

### Function o.spy()
### Function o.spy([Function fn])

@@ -344,0 +367,0 @@ Returns a function that records the number of times it gets called, and its arguments

@@ -52,2 +52,21 @@ "use strict"

})
o("spy wrapping", function() {
var spy = o.spy(function view(vnode){
this.drawn = true
return {tag: "div", children: vnode.children}
})
var children = [""]
var state = {}
var output = spy.call(state, {children: children})
o(spy.length).equals(1)
o(spy.name).equals("view")
o(spy.callCount).equals(1)
o(spy.args.length).equals(1)
o(spy.args[0]).deepEquals({children: children})
o(state).deepEquals({drawn: true})
o(output).deepEquals({tag: "div", children: children})
})
})

@@ -54,0 +73,0 @@ o.spec("async", function() {

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