Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: MithrilJS/ospec
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v4.1.5
Choose a base ref
...
head repository: MithrilJS/ospec
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v4.1.6
Choose a head ref
  • 2 commits
  • 5 files changed
  • 1 contributor

Commits on May 19, 2022

  1. Add tests for v4.1.5

    pygy committed May 19, 2022
    Copy the full SHA
    91db297 View commit details
  2. Copy the full SHA
    6379ceb View commit details
Showing with 55 additions and 20 deletions.
  1. +12 −5 changelog.md
  2. +6 −2 ospec.js
  3. +9 −9 package-lock.json
  4. +2 −2 package.json
  5. +26 −2 tests/test-api.js
17 changes: 12 additions & 5 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -18,30 +18,37 @@ Change log

### Upcoming

- *Nothing so far*
- *Noothing yet*

### 4.1.6
_2022-05-19_

- `.deepEquals()` now ignores non-enumerable keys. This makes `seamless-immutable` objects comparable and fixes [#24](https://github.com/MithrilJS/ospec/issues/24).

### 4.1.5
_2022-05-19_

#### Bug fixes
#### Bug fix

- Properly interpolate values when using assertions to tag templages

```JS
o(x).equals(y)`Description that interpolates ${context}`
```

Will work as expected. This fixes #43
Will work as expected. This fixes [#43](https://github.com/MithrilJS/ospec/issues/43)

### 4.1.4
_2022-05-19_

#### Bug fixes
#### Bug fix

- Work around a Rollup limitation, fixes [#25](https://github.com/MithrilJS/ospec/issues/25) Thanks to [Ivan Kupalov](https://github.com/charlag) for the report and preliminary fix.
- Properly handle objects with a null prototype in `.deepEquals` assertions. Fixes [#41](https://github.com/MithrilJS/ospec/issues/41)

### 4.1.3

#### Bug fixes
#### Bug fix
_2022-05-18_
- Fix post-install crash introduced in v4.1.2

8 changes: 6 additions & 2 deletions ospec.js
Original file line number Diff line number Diff line change
@@ -526,7 +526,11 @@ else window.o = m()
return true
}
}

function getEnumerableProps(x) {
var desc = Object.getOwnPropertyDescriptors(x)
return Object.keys(desc).filter(function(k){return desc[k].enumerable})
}

function deepEqual(a, b) {
if (a === b) return true
if (a === null ^ b === null || a === undefined ^ b === undefined) return false // eslint-disable-line no-bitwise
@@ -542,7 +546,7 @@ else window.o = m()
return true
}
if (a.length === b.length && (Array.isArray(a) && Array.isArray(b) || aIsArgs && bIsArgs)) {
var aKeys = Object.getOwnPropertyNames(a), bKeys = Object.getOwnPropertyNames(b)
var aKeys = getEnumerableProps(a), bKeys = getEnumerableProps(b)
if (aKeys.length !== bKeys.length) return false
for (var i = 0; i < aKeys.length; i++) {
if (!hasOwn.call(b, aKeys[i]) || !deepEqual(a[aKeys[i]], b[aKeys[i]])) return false
18 changes: 9 additions & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ospec",
"version": "4.1.5",
"version": "4.1.6",
"description": "Noiseless testing framework",
"main": "ospec.js",
"unpkg": "ospec.js",
@@ -34,6 +34,6 @@
"cmd-shim": "4.0.2",
"compose-regexp": "^0.6.22",
"eslint": "^6.8.0",
"ospec-stable": "npm:ospec@4.1.4"
"ospec-stable": "npm:ospec@4.1.5"
}
}
28 changes: 26 additions & 2 deletions tests/test-api.js
Original file line number Diff line number Diff line change
@@ -60,7 +60,7 @@ o.spec("no output", function() {
if (spec.toString().indexOf("console") !== -1) {
throw new Error("Avoid referencing the console in the 'no output' test suite. For logging, use the `LOG(...)` helper.")
} else {
o.spec("", spec)
o.spec("-", spec)
}
function spec(){
o("API", function() {
@@ -480,6 +480,19 @@ o.spec("no output", function() {
oo({__proto__: null}).notDeepEquals({__proto__: null, a: 1})
oo({__proto__: null, a: 1}).notDeepEquals({__proto__: null})

// #29
var im1 = [1, 2]
Object.defineProperty(im1, "x", {value: 5, enumrable: false})
var im2 = [1, 2]
Object.defineProperty(im2, "x", {value: 4, enumrable: false})
oo(im1).deepEquals(im2)

var im3 = {y: 4, z: 5}
Object.defineProperty(im3, "x", {value: 5, enumrable: false})
var im4 = {y: 4, z: 5}
Object.defineProperty(im4, "x", {value: 4, enumrable: false})
oo(im3).deepEquals(im4)


oo(function(){throw new Error()}).throws(Error)
oo(function(){"ayy".foo()}).throws(TypeError)
@@ -1338,11 +1351,22 @@ o.spec("no output", function() {
oo("description", function() {
oo(1).equals(2)("howdy")
})
try {
eval("const a = `${5}`")
eval("oo('taggedTemplate', ()=>{oo(1).equals(2)`h${'o'}w${'d'}y`})")
} catch(e) {
oo("taggedTemaplate", function() {
oo(1).equals(2)(['h', 'w', 'y'], 'o', 'd')

})
}
oo.run(function(results) {
try {
o(results.length).equals(2)
o(results.length).equals(3)
o(results[1].message).equals("howdy\n\n"+results[0].message)
o(results[1].pass).equals(false)
o(results[2].message).equals("howdy\n\n"+results[0].message)
o(results[2].pass).equals(false)

done()
} catch (e) {