@hirez_io/auto-spies-core
Advanced tools
Comparing version 1.6.6 to 1.6.7
@@ -6,2 +6,13 @@ # Change Log | ||
## [1.6.7](https://github.com/hirezio/auto-spies/compare/@hirez_io/auto-spies-core@1.6.6...@hirez_io/auto-spies-core@1.6.7) (2022-01-01) | ||
### Bug Fixes | ||
* **core:** change serialize-javascript to javascript-stringify ([6d02a4a](https://github.com/hirezio/auto-spies/commit/6d02a4aa9f0621db700f1ad2e2b49d8b433a4c19)), closes [#55](https://github.com/hirezio/auto-spies/issues/55) | ||
## [1.6.6](https://github.com/hirezio/auto-spies/compare/@hirez_io/auto-spies-core@1.6.5...@hirez_io/auto-spies-core@1.6.6) (2022-01-01) | ||
@@ -8,0 +19,0 @@ |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.ArgsMap = void 0; | ||
// eslint-disable-next-line @typescript-eslint/no-var-requires | ||
var stringify = require('serialize-javascript'); | ||
var javascript_stringify_1 = require("javascript-stringify"); | ||
var ArgsMap = /** @class */ (function () { | ||
@@ -11,7 +10,12 @@ function ArgsMap() { | ||
ArgsMap.prototype.set = function (key, value) { | ||
var keyAsString = stringify(key); | ||
this.map[keyAsString] = value; | ||
var keyAsString = (0, javascript_stringify_1.stringify)(key); | ||
if (keyAsString) { | ||
this.map[keyAsString] = value; | ||
} | ||
}; | ||
ArgsMap.prototype.get = function (key) { | ||
var keyAsString = stringify(key); | ||
var keyAsString = (0, javascript_stringify_1.stringify)(key); | ||
if (!keyAsString) { | ||
return; | ||
} | ||
return this.map[keyAsString]; | ||
@@ -18,0 +22,0 @@ }; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.errorHandler = void 0; | ||
// eslint-disable-next-line @typescript-eslint/no-var-requires | ||
var stringify = require('serialize-javascript'); | ||
var javascript_stringify_1 = require("javascript-stringify"); | ||
exports.errorHandler = { | ||
@@ -13,4 +12,5 @@ throwArgumentsError: function (actualArgs, functionName) { | ||
else { | ||
var formattedArgs = stringify(actualArgs); | ||
formattedArgs = formattedArgs.substring(1, formattedArgs.length - 1); | ||
var formattedArgs = (0, javascript_stringify_1.stringify)(actualArgs); | ||
/* istanbul ignore next */ | ||
formattedArgs = formattedArgs === null || formattedArgs === void 0 ? void 0 : formattedArgs.substring(1, formattedArgs.length - 1); | ||
errorMessage += "\n But the actual arguments were: ".concat(formattedArgs, "\n "); | ||
@@ -17,0 +17,0 @@ } |
{ | ||
"name": "@hirez_io/auto-spies-core", | ||
"version": "1.6.6", | ||
"version": "1.6.7", | ||
"publishConfig": { | ||
@@ -52,3 +52,3 @@ "access": "public" | ||
"dependencies": { | ||
"serialize-javascript": "6.0.0" | ||
"javascript-stringify": "2.1.0" | ||
}, | ||
@@ -59,3 +59,3 @@ "peerDependencies": { | ||
}, | ||
"gitHead": "731349d12356f7afc42b80ac70f2774154ad5d99" | ||
"gitHead": "e1757d9bdb73a7f6b751112853da1e631cc4260a" | ||
} |
@@ -1,3 +0,2 @@ | ||
// eslint-disable-next-line @typescript-eslint/no-var-requires | ||
const stringify = require('serialize-javascript'); | ||
import { stringify } from 'javascript-stringify'; | ||
@@ -9,3 +8,5 @@ export class ArgsMap { | ||
const keyAsString = stringify(key); | ||
this.map[keyAsString] = value; | ||
if (keyAsString) { | ||
this.map[keyAsString] = value; | ||
} | ||
} | ||
@@ -15,4 +16,7 @@ | ||
const keyAsString = stringify(key); | ||
if (!keyAsString) { | ||
return; | ||
} | ||
return this.map[keyAsString]; | ||
} | ||
} |
@@ -1,3 +0,2 @@ | ||
// eslint-disable-next-line @typescript-eslint/no-var-requires | ||
const stringify = require('serialize-javascript'); | ||
import { stringify } from 'javascript-stringify'; | ||
@@ -17,3 +16,4 @@ export const errorHandler = { | ||
let formattedArgs = stringify(actualArgs); | ||
formattedArgs = formattedArgs.substring(1, formattedArgs.length - 1); | ||
/* istanbul ignore next */ | ||
formattedArgs = formattedArgs?.substring(1, formattedArgs.length - 1); | ||
@@ -20,0 +20,0 @@ errorMessage += ` |
@@ -54,6 +54,19 @@ import { errorHandler } from './error-handler'; | ||
expect(actualError).toContain("The function 'fakeFunction' was configured with"); | ||
expect(actualError).toContain('But the actual arguments were: {"yep":1}'); | ||
expect(actualError).toContain('But the actual arguments were: {yep:1}'); | ||
}); | ||
}); | ||
describe('GIVEN actual args of type object do not match', () => { | ||
Given(() => { | ||
fakeActualArgs = [{ doSomething: function () {} }]; | ||
}); | ||
Then('throw error with arguments', () => { | ||
expect(actualError).toContain("The function 'fakeFunction' was configured with"); | ||
expect(actualError).toContain( | ||
'But the actual arguments were: {doSomething:function () { }}' | ||
); | ||
}); | ||
}); | ||
}); | ||
}); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
141689
1696
+ Addedjavascript-stringify@2.1.0
+ Addedjavascript-stringify@2.1.0(transitive)
- Removedserialize-javascript@6.0.0
- Removedrandombytes@2.1.0(transitive)
- Removedsafe-buffer@5.2.1(transitive)
- Removedserialize-javascript@6.0.0(transitive)