From c64858e8592676a64d9e98728dcfbf3d357c0c7c Mon Sep 17 00:00:00 2001 From: Mateusz Karkula Date: Mon, 29 Apr 2019 15:03:18 +0200 Subject: [PATCH] Fix Arg.all() after #30 + add more tests + small refactor (#43) --- dist/spec/Utilities.spec.d.ts | 1 + dist/spec/Utilities.spec.js | 77 ++++++++++++++++++++++ dist/spec/Utilities.spec.js.map | 1 + dist/spec/index.test.js | 8 --- dist/spec/index.test.js.map | 2 +- dist/spec/issues/36.test.d.ts | 1 + dist/spec/issues/36.test.js | 63 ++++++++++++++++++ dist/spec/issues/36.test.js.map | 1 + dist/src/Utilities.js | 11 ++-- dist/src/Utilities.js.map | 2 +- dist/src/states/GetPropertyState.js.map | 2 +- dist/src/states/SetPropertyState.js.map | 2 +- package-lock.json | 6 +- spec/Utilities.spec.ts | 85 +++++++++++++++++++++++++ spec/index.test.ts | 11 ---- src/Utilities.ts | 13 ++-- src/states/GetPropertyState.ts | 2 - src/states/SetPropertyState.ts | 2 +- 18 files changed, 250 insertions(+), 40 deletions(-) create mode 100644 dist/spec/Utilities.spec.d.ts create mode 100644 dist/spec/Utilities.spec.js create mode 100644 dist/spec/Utilities.spec.js.map create mode 100644 dist/spec/issues/36.test.d.ts create mode 100644 dist/spec/issues/36.test.js create mode 100644 dist/spec/issues/36.test.js.map create mode 100644 spec/Utilities.spec.ts diff --git a/dist/spec/Utilities.spec.d.ts b/dist/spec/Utilities.spec.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/dist/spec/Utilities.spec.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/dist/spec/Utilities.spec.js b/dist/spec/Utilities.spec.js new file mode 100644 index 0000000..934b55f --- /dev/null +++ b/dist/spec/Utilities.spec.js @@ -0,0 +1,77 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var ava_1 = require("ava"); +var Utilities_1 = require("../src/Utilities"); +var index_1 = require("../src/index"); +var testObject = { "foo": "bar" }; +var testArray = ["a", 1, true]; +var testFunc = function () { }; +//#region areArgumentArraysEqual +ava_1.default('areArgumentArraysEqual should return valid result for primitive arguments', function (t) { + // single + t.true(Utilities_1.areArgumentArraysEqual([''], [''])); + t.true(Utilities_1.areArgumentArraysEqual(['a'], ['a'])); + t.true(Utilities_1.areArgumentArraysEqual([0], [0])); + t.true(Utilities_1.areArgumentArraysEqual([1], [1])); + t.true(Utilities_1.areArgumentArraysEqual([true], [true])); + t.true(Utilities_1.areArgumentArraysEqual([false], [false])); + t.true(Utilities_1.areArgumentArraysEqual([undefined], [undefined])); + t.true(Utilities_1.areArgumentArraysEqual([null], [null])); + t.true(Utilities_1.areArgumentArraysEqual([testObject], [testObject])); + t.true(Utilities_1.areArgumentArraysEqual([testArray], [testArray])); + t.true(Utilities_1.areArgumentArraysEqual([testFunc], [testFunc])); + t.false(Utilities_1.areArgumentArraysEqual(['a'], ['b'])); + t.false(Utilities_1.areArgumentArraysEqual([1], [2])); + t.false(Utilities_1.areArgumentArraysEqual([true], [false])); + t.false(Utilities_1.areArgumentArraysEqual([undefined], [null])); + t.false(Utilities_1.areArgumentArraysEqual([testObject], [testArray])); + // multi + t.true(Utilities_1.areArgumentArraysEqual([1, 2, 3], [1, 2, 3])); + t.false(Utilities_1.areArgumentArraysEqual([1, 2, 3], [3, 2, 1])); + t.false(Utilities_1.areArgumentArraysEqual([1, 2, 3, 4], [1, 2, 3])); + t.false(Utilities_1.areArgumentArraysEqual([1, 2, 3], [1, 2, 3, 4])); +}); +ava_1.default('areArgumentArraysEqual should return valid result using Arg.all()', function (t) { + t.true(Utilities_1.areArgumentArraysEqual([index_1.Arg.all()], [])); + t.true(Utilities_1.areArgumentArraysEqual([index_1.Arg.all()], [0])); + t.true(Utilities_1.areArgumentArraysEqual([index_1.Arg.all()], [1])); + t.true(Utilities_1.areArgumentArraysEqual([index_1.Arg.all()], ['string'])); + t.true(Utilities_1.areArgumentArraysEqual([index_1.Arg.all()], [true])); + t.true(Utilities_1.areArgumentArraysEqual([index_1.Arg.all()], [false])); + t.true(Utilities_1.areArgumentArraysEqual([index_1.Arg.all()], [null])); + t.true(Utilities_1.areArgumentArraysEqual([index_1.Arg.all()], [undefined])); + t.true(Utilities_1.areArgumentArraysEqual([index_1.Arg.all()], [1, 2])); + t.true(Utilities_1.areArgumentArraysEqual([index_1.Arg.all()], ['string1', 'string2'])); +}); +ava_1.default('areArgumentArraysEqual should return valid result using Arg.any()', function (t) { + t.true(Utilities_1.areArgumentArraysEqual([index_1.Arg.any()], ['hi'])); + t.true(Utilities_1.areArgumentArraysEqual([index_1.Arg.any()], [1])); + t.true(Utilities_1.areArgumentArraysEqual([index_1.Arg.any()], [0])); + t.true(Utilities_1.areArgumentArraysEqual([index_1.Arg.any()], [false])); + t.true(Utilities_1.areArgumentArraysEqual([index_1.Arg.any()], [true])); + t.true(Utilities_1.areArgumentArraysEqual([index_1.Arg.any()], [null])); + t.true(Utilities_1.areArgumentArraysEqual([index_1.Arg.any()], [undefined])); + t.true(Utilities_1.areArgumentArraysEqual([index_1.Arg.any()], [testObject])); + t.true(Utilities_1.areArgumentArraysEqual([index_1.Arg.any()], [testArray])); + t.true(Utilities_1.areArgumentArraysEqual([index_1.Arg.any()], [testFunc])); + t.true(Utilities_1.areArgumentArraysEqual([index_1.Arg.any()], [])); + t.true(Utilities_1.areArgumentArraysEqual([index_1.Arg.any('string')], ['foo'])); + t.true(Utilities_1.areArgumentArraysEqual([index_1.Arg.any('number')], [1])); + t.true(Utilities_1.areArgumentArraysEqual([index_1.Arg.any('boolean')], [true])); + t.true(Utilities_1.areArgumentArraysEqual([index_1.Arg.any('object')], [testObject])); + t.true(Utilities_1.areArgumentArraysEqual([index_1.Arg.any('array')], [testArray])); + t.true(Utilities_1.areArgumentArraysEqual([index_1.Arg.any('function')], [testFunc])); + t.false(Utilities_1.areArgumentArraysEqual([index_1.Arg.any('string')], [1])); + t.false(Utilities_1.areArgumentArraysEqual([index_1.Arg.any('number')], ['string'])); + t.false(Utilities_1.areArgumentArraysEqual([index_1.Arg.any('boolean')], [null])); + t.false(Utilities_1.areArgumentArraysEqual([index_1.Arg.any('object')], ['foo'])); + t.false(Utilities_1.areArgumentArraysEqual([index_1.Arg.any('array')], ['bar'])); + t.false(Utilities_1.areArgumentArraysEqual([index_1.Arg.any('function')], ['foo'])); +}); +ava_1.default('areArgumentArraysEqual should return valid result using Arg.is()', function (t) { + t.true(Utilities_1.areArgumentArraysEqual([index_1.Arg.is(function (x) { return x === 'foo'; })], ['foo'])); + t.true(Utilities_1.areArgumentArraysEqual([index_1.Arg.is(function (x) { return x % 2 == 0; })], [4])); + t.false(Utilities_1.areArgumentArraysEqual([index_1.Arg.is(function (x) { return x === 'foo'; })], ['bar'])); + t.false(Utilities_1.areArgumentArraysEqual([index_1.Arg.is(function (x) { return x % 2 == 0; })], [3])); +}); +//# sourceMappingURL=Utilities.spec.js.map \ No newline at end of file diff --git a/dist/spec/Utilities.spec.js.map b/dist/spec/Utilities.spec.js.map new file mode 100644 index 0000000..a5a3040 --- /dev/null +++ b/dist/spec/Utilities.spec.js.map @@ -0,0 +1 @@ +{"version":3,"file":"Utilities.spec.js","sourceRoot":"","sources":["../../spec/Utilities.spec.ts"],"names":[],"mappings":";;AAAA,2BAAuB;AACvB,8CAA0D;AAC1D,sCAAmC;AAEnC,IAAM,UAAU,GAAG,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;AACpC,IAAM,SAAS,GAAG,CAAC,GAAG,EAAE,CAAC,EAAE,IAAI,CAAC,CAAC;AACjC,IAAM,QAAQ,GAAG,cAAO,CAAC,CAAC;AAE1B,gCAAgC;AAChC,aAAI,CAAC,2EAA2E,EAAE,UAAA,CAAC;IAC/E,UAAU;IACV,CAAC,CAAC,IAAI,CAAC,kCAAsB,CAAC,CAAC,EAAE,CAAC,EAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IAC1C,CAAC,CAAC,IAAI,CAAC,kCAAsB,CAAC,CAAC,GAAG,CAAC,EAAC,CAAC,GAAG,CAAC,CAAC,C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';\r\nimport { Arg } from '../src/index';\r\n\r\nconst testObject = { \"foo\": \"bar\" };\r\nconst testArray = [\"a\", 1, true];\r\nconst testFunc = () => {};\r\n\r\n//#region areArgumentArraysEqual\r\ntest('areArgumentArraysEqual should return valid result for primitive arguments', t => {\r\n // single \r\n t.true(areArgumentArraysEqual([''],['']));\r\n t.true(areArgumentArraysEqual(['a'],['a']));\r\n t.true(areArgumentArraysEqual([0],[0]));\r\n t.true(areArgumentArraysEqual([1],[1]));\r\n t.true(areArgumentArraysEqual([true],[true]));\r\n t.true(areArgumentArraysEqual([false],[false]));\r\n t.true(areArgumentArraysEqual([undefined],[undefined]));\r\n t.true(areArgumentArraysEqual([null],[null]));\r\n t.true(areArgumentArraysEqual([testObject],[testObject]));\r\n t.true(areArgumentArraysEqual([testArray],[testArray]));\r\n t.true(areArgumentArraysEqual([testFunc],[testFunc]));\r\n\r\n t.false(areArgumentArraysEqual(['a'],['b']));\r\n t.false(areArgumentArraysEqual([1],[2]));\r\n t.false(areArgumentArraysEqual([true],[false]));\r\n t.false(areArgumentArraysEqual([undefined],[null]));\r\n t.false(areArgumentArraysEqual([testObject],[testArray]));\r\n\r\n // multi\r\n t.true(areArgumentArraysEqual([1,2,3], [1,2,3]));\r\n\r\n t.false(areArgumentArraysEqual([1,2,3], [3,2,1]));\r\n t.false(areArgumentArraysEqual([1,2,3,4], [1,2,3]));\r\n t.false(areArgumentArraysEqual([1,2,3], [1,2,3,4])); \r\n})\r\n\r\ntest('areArgumentArraysEqual should return valid result using Arg.all()', t => {\r\n t.true(areArgumentArraysEqual([Arg.all()],[]));\r\n t.true(areArgumentArraysEqual([Arg.all()],[0]));\r\n t.true(areArgumentArraysEqual([Arg.all()],[1]));\r\n t.true(areArgumentArraysEqual([Arg.all()],['string']));\r\n t.true(areArgumentArraysEqual([Arg.all()],[true]));\r\n t.true(areArgumentArraysEqual([Arg.all()],[false]));\r\n t.true(areArgumentArraysEqual([Arg.all()],[null]));\r\n t.true(areArgumentArraysEqual([Arg.all()],[undefined]));\r\n t.true(areArgumentArraysEqual([Arg.all()],[1,2]));\r\n t.true(areArgumentArraysEqual([Arg.all()],['string1', 'string2']));\r\n})\r\n\r\ntest('areArgumentArraysEqual should return valid result using Arg.any()', t => {\r\n t.true(areArgumentArraysEqual([Arg.any()], ['hi']));\r\n t.true(areArgumentArraysEqual([Arg.any()], [1]));\r\n t.true(areArgumentArraysEqual([Arg.any()], [0]));\r\n t.true(areArgumentArraysEqual([Arg.any()], [false]));\r\n t.true(areArgumentArraysEqual([Arg.any()], [true]));\r\n t.true(areArgumentArraysEqual([Arg.any()], [null]));\r\n t.true(areArgumentArraysEqual([Arg.any()], [undefined]));\r\n t.true(areArgumentArraysEqual([Arg.any()], [testObject]));\r\n t.true(areArgumentArraysEqual([Arg.any()], [testArray]));\r\n t.true(areArgumentArraysEqual([Arg.any()], [testFunc]));\r\n t.true(areArgumentArraysEqual([Arg.any()], []));\r\n\r\n t.true(areArgumentArraysEqual([Arg.any('string')], ['foo']));\r\n t.true(areArgumentArraysEqual([Arg.any('number')], [1]));\r\n t.true(areArgumentArraysEqual([Arg.any('boolean')], [true]));\r\n t.true(areArgumentArraysEqual([Arg.any('object')], [testObject]));\r\n t.true(areArgumentArraysEqual([Arg.any('array')], [testArray]));\r\n t.true(areArgumentArraysEqual([Arg.any('function')], [testFunc]));\r\n\r\n t.false(areArgumentArraysEqual([Arg.any('string')], [1]));\r\n t.false(areArgumentArraysEqual([Arg.any('number')], ['string']));\r\n t.false(areArgumentArraysEqual([Arg.any('boolean')], [null]));\r\n t.false(areArgumentArraysEqual([Arg.any('object')], ['foo']));\r\n t.false(areArgumentArraysEqual([Arg.any('array')], ['bar']));\r\n t.false(areArgumentArraysEqual([Arg.any('function')], ['foo']));\r\n})\r\n\r\ntest('areArgumentArraysEqual should return valid result using Arg.is()', t => {\r\n t.true(areArgumentArraysEqual([Arg.is(x => x === 'foo')], ['foo']));\r\n t.true(areArgumentArraysEqual([Arg.is(x => x % 2 == 0)], [4]));\r\n\r\n t.false(areArgumentArraysEqual([Arg.is(x => x === 'foo')], ['bar']));\r\n t.false(areArgumentArraysEqual([Arg.is(x => x % 2 == 0)], [3]));\r\n});"]} \ No newline at end of file diff --git a/dist/spec/index.test.js b/dist/spec/index.test.js index 86f8fb3..2ec0113 100644 --- a/dist/spec/index.test.js +++ b/dist/spec/index.test.js @@ -38,7 +38,6 @@ var _this = this; Object.defineProperty(exports, "__esModule", { value: true }); var ava_1 = require("ava"); var index_1 = require("../src/index"); -var Utilities_1 = require("../src/Utilities"); var Dummy = /** @class */ (function () { function Dummy() { } @@ -230,13 +229,6 @@ ava_1.default('partial mocks using property instance mimicks', function (t) { substitute.d.mimicks(function () { return instance.d; }); t.deepEqual(substitute.d, 1337); }); -ava_1.default('are arguments equal', function (t) { - initialize(); - t.true(Utilities_1.areArgumentsEqual(index_1.Arg.any(), 'hi')); - t.true(Utilities_1.areArgumentsEqual(index_1.Arg.any('array'), ['foo', 'bar'])); - t.false(Utilities_1.areArgumentsEqual(['foo', 'bar'], ['foo', 'bar'])); - t.false(Utilities_1.areArgumentsEqual(index_1.Arg.any('array'), 1337)); -}); ava_1.default('verifying with more arguments fails', function (t) { initialize(); substitute.bar(1); diff --git a/dist/spec/index.test.js.map b/dist/spec/index.test.js.map index 334191d..ed1c93f 100644 --- a/dist/spec/index.test.js.map +++ b/dist/spec/index.test.js.map @@ -1 +1 @@ -{"version":3,"file":"index.test.js","sourceRoot":"","sources":["../../spec/index.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iBA8SE;;AA9SF,2BAAuB;AAEvB,sCAA+C;AAC/C,8CAAqD;AAGrD;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAED;IAAA;QACC,MAAC,GAAG,MAAM,CAAC;IA4BZ,CAAC;IA1BA,mBAAC,GAAD,UAAE,IAAY,EAAE,IAAY;QAC3B,OAAO,QAAQ,GAAG,IAAI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CAAA;IAC1B,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAA;AAC9B,CAAC,CAAC,CAAA","sourcesContent":["import test from 'ava';\r\n\r\nimport { Substitute, Arg } from '../src/index';\r\nimport { areArgumentsEqual } from '../src/Utilities';\r\nimport { OmitProxyMethods, ObjectSubstitute } from '../src/Transformations';\r\n\r\nclass Dummy {\r\n\r\n}\r\n\r\nexport class Example {\r\n\ta = \"1337\";\r\n\r\n\tc(arg1: string, arg2: string) {\r\n\t\treturn \"hello \" + arg1 + \" world (\" + arg2 + \")\";\r\n\t}\r\n\r\n\tget d() {\r\n\t\treturn 1337;\r\n\t}\r\n\r\n\tset v(x: string|null|undefined) {\r\n\t}\r\n\r\n\treceived(stuff: number|string) {\r\n\r\n\t}\r\n\r\n\treturnPromise() {\r\n\t\treturn Promise.resolve(new Dummy());\r\n\t}\r\n\r\n\tfoo(): string|undefined|null {\r\n\t\treturn 'stuff';\r\n }\r\n \r\n bar (a: number, b?: number): number{\r\n return a + b || 0\r\n }\r\n}\r\n\r\nlet instance: Example;\r\nlet substitute: ObjectSubstitute, Example>;\r\n\r\nfunction initialize() {\r\n\tinstance = new Example();\r\n\tsubstitute = Substitute.for();\r\n};\r\n\r\ntest('can call received twice', t => { \r\n\tinitialize();\r\n\r\n\tsubstitute.c('blah', 'fuzz');\r\n\r\n\tt.throws(() => substitute.received(1337).c('foo', 'bar'), \r\n`Expected 1337 calls to the method c with arguments ['foo', 'bar'], but received none of such calls.\r\nAll calls received to method c:\r\n-> call with arguments ['blah', 'fuzz']`);\r\n\r\n\tt.throws(() => substitute.received(2117).c('foo', 'bar'),\r\n`Expected 2117 calls to the method c with arguments ['foo', 'bar'], but received none of such calls.\r\nAll calls received to method c:\r\n-> call with arguments ['blah', 'fuzz']`);\r\n});\r\n\r\ntest('class string field get returns', t => {\r\n\tinitialize();\r\n\r\n\tsubstitute.a.returns(\"foo\", \"bar\");\r\n\r\n\tt.deepEqual(substitute.a, 'foo');\r\n\tt.deepEqual(substitute.a, 'bar');\r\n\tt.deepEqual(substitute.a, void 0);\r\n\tt.deepEqual(substitute.a, void 0);\r\n});\r\n\r\ntest('class with method called \"received\" can be used for call count verification when proxies are suspended', t => {\r\n\tinitialize();\r\n\t\r\n\tSubstitute.disableFor(substitute).received(2);\r\n\r\n\tt.throws(() => substitute.received(2).received(2));\r\n\tt.notThrows(() => substitute.received(1).received(2));\r\n});\r\n\r\ntest('class with method called \"received\" can be used for call count verification', t => {\r\n\tinitialize();\r\n\t\r\n\tSubstitute.disableFor(substitute).received('foo');\r\n\r\n\tt.notThrows(() => substitute.received(1).received('foo'));\r\n\tt.throws(() => substitute.received(2).received('foo'));\r\n});\r\n\r\ntest('partial mocks using function mimicks with all args', t => {\r\n\tinitialize();\r\n\t\r\n\tsubstitute.c(Arg.all()).mimicks(instance.c);\r\n\r\n\tt.deepEqual(substitute.c('a', 'b'), 'hello a world (b)');\r\n});\r\n\r\ntest('class string field get received', t => {\r\n\tinitialize();\r\n\t\r\n\tvoid substitute.a;\r\n\tvoid substitute.a;\r\n\tvoid substitute.a;\r\n\tvoid substitute.a;\r\n\r\n\tt.throws(() => substitute.received(3).a);\r\n\tt.notThrows(() => substitute.received().a);\r\n\tt.notThrows(() => substitute.received(4).a);\r\n});\r\n\r\ntest('class string field set received', t => {\r\n\tinitialize();\r\n\t\r\n\tsubstitute.v = undefined;\r\n\tsubstitute.v = null;\r\n\tsubstitute.v = 'hello';\r\n\tsubstitute.v = 'hello';\r\n\tsubstitute.v = 'world';\r\n\t\r\n\tt.notThrows(() => substitute.received().v = 'hello');\r\n\tt.notThrows(() => substitute.received(5).v = Arg.any());\r\n\tt.notThrows(() => substitute.received().v = Arg.any());\r\n\tt.notThrows(() => substitute.received(2).v = 'hello');\r\n\tt.notThrows(() => substitute.received(2).v = Arg.is(x => x && x.indexOf('ll') > -1));\r\n\r\n\tt.throws(() => substitute.received(2).v = Arg.any());\r\n\tt.throws(() => substitute.received(1).v = Arg.any());\r\n\tt.throws(() => substitute.received(1).v = Arg.is(x => x && x.indexOf('ll') > -1));\r\n\tt.throws(() => substitute.received(3).v = 'hello');\r\n});\r\n\r\ntest('class method returns with placeholder args', t => {\r\n\tinitialize();\r\n\t\r\n\tsubstitute.c(Arg.any(), \"there\").returns(\"blah\", \"haha\");\r\n\t\r\n\tt.is(substitute.c(\"hi\", \"there\"), 'blah');\r\n\tt.is(substitute.c(\"his\", \"there\"), 'haha');\r\n\tt.is(substitute.c(\"his\", \"there\"), void 0);\r\n\tt.is(substitute.c(\"hi\", \"there\"), void 0);\r\n});\r\n\r\ntest('partial mocks using function mimicks with specific args', t => {\r\n\tinitialize();\r\n\t\r\n\tsubstitute.c('a', 'b').mimicks(instance.c);\r\n\r\n\tt.is(substitute.c('a', 'b'), 'hello a world (b)');\r\n});\r\n\r\ntest('class method returns with specific args', t => {\r\n\tinitialize();\r\n\t\r\n\tsubstitute.c(\"hi\", \"there\").returns(\"blah\", \"haha\");\r\n\r\n\tt.is(substitute.c(\"hi\", \"there\"), 'blah');\r\n\tt.is(substitute.c(\"hi\", \"there\"), 'haha');\r\n\tt.is(substitute.c(\"hi\", \"there\"), void 0);\r\n\tt.is(substitute.c(\"hi\", \"there\"), void 0);\r\n});\r\n\r\ntest('returning other fake from promise works', async t => {\r\n\tinitialize();\r\n\t\r\n\tconst otherSubstitute = Substitute.for();\r\n\tsubstitute.returnPromise().returns(Promise.resolve(otherSubstitute));\r\n t.is(otherSubstitute, await substitute.returnPromise());\r\n});\r\n\r\ntest('returning resolved promises works', async t => {\r\n\tinitialize();\r\n\t\r\n\tsubstitute.returnPromise().returns(Promise.resolve(1338));\r\n\r\n\tt.is(1338, await substitute.returnPromise());\r\n});\r\n\r\ntest('class void returns', t => {\r\n\tinitialize();\r\n\t\r\n\tsubstitute.foo().returns(void 0, null);\r\n\r\n\tt.is(substitute.foo(), void 0);\r\n\tt.is(substitute.foo(), null);\r\n}); \r\n\r\ntest('class method received', t => {\r\n\tinitialize();\r\n\t\r\n\tvoid substitute.c(\"hi\", \"there\");\r\n\tvoid substitute.c(\"hi\", \"the1re\");\r\n\tvoid substitute.c(\"hi\", \"there\");\r\n\tvoid substitute.c(\"hi\", \"there\");\r\n\tvoid substitute.c(\"hi\", \"there\");\r\n\r\n\tt.notThrows(() => substitute.received(4).c('hi', 'there'));\r\n\tt.notThrows(() => substitute.received(1).c('hi', 'the1re'));\r\n\tt.notThrows(() => substitute.received().c('hi', 'there'));\r\n\r\n\tt.throws(() => substitute.received(7).c('hi', 'there'), \r\n`Expected 7 calls to the method c with arguments ['hi', 'there'], but received 4 of such calls.\r\nAll calls received to method c:\r\n-> call with arguments ['hi', 'there']\r\n-> call with arguments ['hi', 'the1re']\r\n-> call with arguments ['hi', 'there']\r\n-> call with arguments ['hi', 'there']\r\n-> call with arguments ['hi', 'there']`);\r\n});\r\n\r\ntest('received call matches after partial mocks using property instance mimicks', t => {\r\n\tinitialize();\r\n\t\r\n\tsubstitute.d.mimicks(() => instance.d);\r\n\tsubstitute.c('lala', 'bar');\r\n\r\n\tsubstitute.received(1).c('lala', 'bar');\r\n\tsubstitute.received(1).c('lala', 'bar');\r\n\r\n\tt.notThrows(() => substitute.received(1).c('lala', 'bar'));\r\n\tt.throws(() => substitute.received(2).c('lala', 'bar'),\r\n`Expected 2 calls to the method c with arguments ['lala', 'bar'], but received 1 of such call.\r\nAll calls received to method c:\r\n-> call with arguments ['lala', 'bar']`);\r\n\t\r\n\tt.deepEqual(substitute.d, 1337);\r\n});\r\n\r\ntest('partial mocks using property instance mimicks', t => {\r\n\tinitialize();\r\n\t\r\n\tsubstitute.d.mimicks(() => instance.d);\r\n\r\n\tt.deepEqual(substitute.d, 1337);\r\n});\r\n\r\ntest('are arguments equal', t => {\r\n\tinitialize();\r\n\t\r\n\tt.true(areArgumentsEqual(Arg.any(), 'hi'));\r\n\tt.true(areArgumentsEqual(Arg.any('array'), ['foo', 'bar']));\r\n\r\n\tt.false(areArgumentsEqual(['foo', 'bar'], ['foo', 'bar']));\r\n\tt.false(areArgumentsEqual(Arg.any('array'), 1337));\r\n});\r\n\r\ntest('verifying with more arguments fails', t => {\r\n initialize()\r\n substitute.bar(1)\r\n substitute.received().bar(1)\r\n t.throws(() => substitute.received().bar(1, 2))\r\n})\r\n\r\ntest('verifying with less arguments fails', t => {\r\n initialize()\r\n substitute.bar(1, 2)\r\n substitute.received().bar(1, 2)\r\n t.throws(() => substitute.received().bar(1))\r\n})\r\n\r\ntest('return with more arguments is not matched fails', t => {\r\n initialize()\r\n substitute.bar(1, 2).returns(3)\r\n t.is(3, substitute.bar(1, 2))\r\n t.is('function', typeof(substitute.bar(1)))\r\n})\r\n\r\ntest('return with less arguments is not matched', t => {\r\n initialize()\r\n substitute.bar(1).returns(3)\r\n t.is(3, substitute.bar(1))\r\n t.is('function', typeof(substitute.bar(1, 2).toString))\r\n})\r\n\r\ntest('can stub multiple primitive return values', t => {\r\n initialize()\r\n substitute.bar(1).returns(2)\r\n substitute.bar(2).returns(3)\r\n t.is(2, substitute.bar(1))\r\n t.is(3, substitute.bar(2))\r\n})\r\n\r\ntest('can stub multiple Arg values', t => {\r\n initialize()\r\n substitute.bar(Arg.is(x => x % 2 === 0)).returns(1)\r\n substitute.bar(Arg.is(x => x % 2 !== 0)).returns(2)\r\n t.is(1, substitute.bar(4))\r\n t.is(2, substitute.bar(5))\r\n})\r\n\r\n\r\ntest.skip('can stub primitive & Arg values', t => {\r\n initialize()\r\n substitute.bar(1).returns(2)\r\n substitute.bar(Arg.any()).returns(3) // throws 'substitute.bar(...).returns is not a function'\r\n t.is(5, substitute.bar(2))\r\n t.is(2, substitute.bar(1))\r\n t.is(3, substitute.bar(2))\r\n})"]} \ No newline at end of file +{"version":3,"file":"index.test.js","sourceRoot":"","sources":["../../spec/index.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iBAmSE;;AAnSF,2BAAuB;AAEvB,sC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AAC,OAAO,CAAC,CAAC,CAAC,CAAA;IACnD,UAAU,CAAC,GAAG,CAAC,WAAG,CAAC,EAAE,CAAC,UAAA,CAAC,IAAI,OAAA,CAAC,GAAG,CAAC,KAAK,CAAC,EAAX,CAAW,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAA;IACnD,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAA;IAC1B,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAA;AAC9B,CAAC,CAAC,CAAA;AAGF,aAAI,CAAC,IAAI,CAAC,iCAAiC,EAAE,UAAA,CAAC;IAC1C,UAAU,EAAE,CAAA;IACZ,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAA;IAC5B,UAAU,CAAC,GAAG,CAAC,WAAG,CAAC,GAAG,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAA,CAAC,yDAAyD;IAC9F,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAA;IAC1B,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAA;IAC1B,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAA;AAC9B,CAAC,CAAC,CAAA","sourcesContent":["import test from 'ava';\r\n\r\nimport { Substitute, Arg } from '../src/index';\r\nimport { OmitProxyMethods, ObjectSubstitute } from '../src/Transformations';\r\n\r\nclass Dummy {\r\n\r\n}\r\n\r\nexport class Example {\r\n\ta = \"1337\";\r\n\r\n\tc(arg1: string, arg2: string) {\r\n\t\treturn \"hello \" + arg1 + \" world (\" + arg2 + \")\";\r\n\t}\r\n\r\n\tget d() {\r\n\t\treturn 1337;\r\n\t}\r\n\r\n\tset v(x: string|null|undefined) {\r\n\t}\r\n\r\n\treceived(stuff: number|string) {\r\n\r\n\t}\r\n\r\n\treturnPromise() {\r\n\t\treturn Promise.resolve(new Dummy());\r\n\t}\r\n\r\n\tfoo(): string|undefined|null {\r\n\t\treturn 'stuff';\r\n }\r\n \r\n bar (a: number, b?: number): number{\r\n return a + b || 0\r\n }\r\n}\r\n\r\nlet instance: Example;\r\nlet substitute: ObjectSubstitute, Example>;\r\n\r\nfunction initialize() {\r\n\tinstance = new Example();\r\n\tsubstitute = Substitute.for();\r\n};\r\n\r\ntest('can call received twice', t => { \r\n\tinitialize();\r\n\r\n\tsubstitute.c('blah', 'fuzz');\r\n\r\n\tt.throws(() => substitute.received(1337).c('foo', 'bar'), \r\n`Expected 1337 calls to the method c with arguments ['foo', 'bar'], but received none of such calls.\r\nAll calls received to method c:\r\n-> call with arguments ['blah', 'fuzz']`);\r\n\r\n\tt.throws(() => substitute.received(2117).c('foo', 'bar'),\r\n`Expected 2117 calls to the method c with arguments ['foo', 'bar'], but received none of such calls.\r\nAll calls received to method c:\r\n-> call with arguments ['blah', 'fuzz']`);\r\n});\r\n\r\ntest('class string field get returns', t => {\r\n\tinitialize();\r\n\r\n\tsubstitute.a.returns(\"foo\", \"bar\");\r\n\r\n\tt.deepEqual(substitute.a, 'foo');\r\n\tt.deepEqual(substitute.a, 'bar');\r\n\tt.deepEqual(substitute.a, void 0);\r\n\tt.deepEqual(substitute.a, void 0);\r\n});\r\n\r\ntest('class with method called \"received\" can be used for call count verification when proxies are suspended', t => {\r\n\tinitialize();\r\n\t\r\n\tSubstitute.disableFor(substitute).received(2);\r\n\r\n\tt.throws(() => substitute.received(2).received(2));\r\n\tt.notThrows(() => substitute.received(1).received(2));\r\n});\r\n\r\ntest('class with method called \"received\" can be used for call count verification', t => {\r\n\tinitialize();\r\n\t\r\n\tSubstitute.disableFor(substitute).received('foo');\r\n\r\n\tt.notThrows(() => substitute.received(1).received('foo'));\r\n\tt.throws(() => substitute.received(2).received('foo'));\r\n});\r\n\r\ntest('partial mocks using function mimicks with all args', t => {\r\n\tinitialize();\r\n\t\r\n\tsubstitute.c(Arg.all()).mimicks(instance.c);\r\n\r\n\tt.deepEqual(substitute.c('a', 'b'), 'hello a world (b)');\r\n});\r\n\r\ntest('class string field get received', t => {\r\n\tinitialize();\r\n\t\r\n\tvoid substitute.a;\r\n\tvoid substitute.a;\r\n\tvoid substitute.a;\r\n\tvoid substitute.a;\r\n\r\n\tt.throws(() => substitute.received(3).a);\r\n\tt.notThrows(() => substitute.received().a);\r\n\tt.notThrows(() => substitute.received(4).a);\r\n});\r\n\r\ntest('class string field set received', t => {\r\n\tinitialize();\r\n\t\r\n\tsubstitute.v = undefined;\r\n\tsubstitute.v = null;\r\n\tsubstitute.v = 'hello';\r\n\tsubstitute.v = 'hello';\r\n\tsubstitute.v = 'world';\r\n\t\r\n\tt.notThrows(() => substitute.received().v = 'hello');\r\n\tt.notThrows(() => substitute.received(5).v = Arg.any());\r\n\tt.notThrows(() => substitute.received().v = Arg.any());\r\n\tt.notThrows(() => substitute.received(2).v = 'hello');\r\n\tt.notThrows(() => substitute.received(2).v = Arg.is(x => x && x.indexOf('ll') > -1));\r\n\r\n\tt.throws(() => substitute.received(2).v = Arg.any());\r\n\tt.throws(() => substitute.received(1).v = Arg.any());\r\n\tt.throws(() => substitute.received(1).v = Arg.is(x => x && x.indexOf('ll') > -1));\r\n\tt.throws(() => substitute.received(3).v = 'hello');\r\n});\r\n\r\ntest('class method returns with placeholder args', t => {\r\n\tinitialize();\r\n\t\r\n\tsubstitute.c(Arg.any(), \"there\").returns(\"blah\", \"haha\");\r\n\t\r\n\tt.is(substitute.c(\"hi\", \"there\"), 'blah');\r\n\tt.is(substitute.c(\"his\", \"there\"), 'haha');\r\n\tt.is(substitute.c(\"his\", \"there\"), void 0);\r\n\tt.is(substitute.c(\"hi\", \"there\"), void 0);\r\n});\r\n\r\ntest('partial mocks using function mimicks with specific args', t => {\r\n\tinitialize();\r\n\t\r\n\tsubstitute.c('a', 'b').mimicks(instance.c);\r\n\r\n\tt.is(substitute.c('a', 'b'), 'hello a world (b)');\r\n});\r\n\r\ntest('class method returns with specific args', t => {\r\n\tinitialize();\r\n\t\r\n\tsubstitute.c(\"hi\", \"there\").returns(\"blah\", \"haha\");\r\n\r\n\tt.is(substitute.c(\"hi\", \"there\"), 'blah');\r\n\tt.is(substitute.c(\"hi\", \"there\"), 'haha');\r\n\tt.is(substitute.c(\"hi\", \"there\"), void 0);\r\n\tt.is(substitute.c(\"hi\", \"there\"), void 0);\r\n});\r\n\r\ntest('returning other fake from promise works', async t => {\r\n\tinitialize();\r\n\t\r\n\tconst otherSubstitute = Substitute.for();\r\n\tsubstitute.returnPromise().returns(Promise.resolve(otherSubstitute));\r\n t.is(otherSubstitute, await substitute.returnPromise());\r\n});\r\n\r\ntest('returning resolved promises works', async t => {\r\n\tinitialize();\r\n\t\r\n\tsubstitute.returnPromise().returns(Promise.resolve(1338));\r\n\r\n\tt.is(1338, await substitute.returnPromise());\r\n});\r\n\r\ntest('class void returns', t => {\r\n\tinitialize();\r\n\t\r\n\tsubstitute.foo().returns(void 0, null);\r\n\r\n\tt.is(substitute.foo(), void 0);\r\n\tt.is(substitute.foo(), null);\r\n}); \r\n\r\ntest('class method received', t => {\r\n\tinitialize();\r\n\t\r\n\tvoid substitute.c(\"hi\", \"there\");\r\n\tvoid substitute.c(\"hi\", \"the1re\");\r\n\tvoid substitute.c(\"hi\", \"there\");\r\n\tvoid substitute.c(\"hi\", \"there\");\r\n\tvoid substitute.c(\"hi\", \"there\");\r\n\r\n\tt.notThrows(() => substitute.received(4).c('hi', 'there'));\r\n\tt.notThrows(() => substitute.received(1).c('hi', 'the1re'));\r\n\tt.notThrows(() => substitute.received().c('hi', 'there'));\r\n\r\n\tt.throws(() => substitute.received(7).c('hi', 'there'), \r\n`Expected 7 calls to the method c with arguments ['hi', 'there'], but received 4 of such calls.\r\nAll calls received to method c:\r\n-> call with arguments ['hi', 'there']\r\n-> call with arguments ['hi', 'the1re']\r\n-> call with arguments ['hi', 'there']\r\n-> call with arguments ['hi', 'there']\r\n-> call with arguments ['hi', 'there']`);\r\n});\r\n\r\ntest('received call matches after partial mocks using property instance mimicks', t => {\r\n\tinitialize();\r\n\t\r\n\tsubstitute.d.mimicks(() => instance.d);\r\n\tsubstitute.c('lala', 'bar');\r\n\r\n\tsubstitute.received(1).c('lala', 'bar');\r\n\tsubstitute.received(1).c('lala', 'bar');\r\n\r\n\tt.notThrows(() => substitute.received(1).c('lala', 'bar'));\r\n\tt.throws(() => substitute.received(2).c('lala', 'bar'),\r\n`Expected 2 calls to the method c with arguments ['lala', 'bar'], but received 1 of such call.\r\nAll calls received to method c:\r\n-> call with arguments ['lala', 'bar']`);\r\n\t\r\n\tt.deepEqual(substitute.d, 1337);\r\n});\r\n\r\ntest('partial mocks using property instance mimicks', t => {\r\n\tinitialize();\r\n\t\r\n\tsubstitute.d.mimicks(() => instance.d);\r\n\r\n\tt.deepEqual(substitute.d, 1337);\r\n});\r\n\r\ntest('verifying with more arguments fails', t => {\r\n initialize()\r\n substitute.bar(1)\r\n substitute.received().bar(1)\r\n t.throws(() => substitute.received().bar(1, 2))\r\n})\r\n\r\ntest('verifying with less arguments fails', t => {\r\n initialize()\r\n substitute.bar(1, 2)\r\n substitute.received().bar(1, 2)\r\n t.throws(() => substitute.received().bar(1))\r\n})\r\n\r\ntest('return with more arguments is not matched fails', t => {\r\n initialize()\r\n substitute.bar(1, 2).returns(3)\r\n t.is(3, substitute.bar(1, 2))\r\n t.is('function', typeof(substitute.bar(1)))\r\n})\r\n\r\ntest('return with less arguments is not matched', t => {\r\n initialize()\r\n substitute.bar(1).returns(3)\r\n t.is(3, substitute.bar(1))\r\n t.is('function', typeof(substitute.bar(1, 2).toString))\r\n})\r\n\r\ntest('can stub multiple primitive return values', t => {\r\n initialize()\r\n substitute.bar(1).returns(2)\r\n substitute.bar(2).returns(3)\r\n t.is(2, substitute.bar(1))\r\n t.is(3, substitute.bar(2))\r\n})\r\n\r\ntest('can stub multiple Arg values', t => {\r\n initialize()\r\n substitute.bar(Arg.is(x => x % 2 === 0)).returns(1)\r\n substitute.bar(Arg.is(x => x % 2 !== 0)).returns(2)\r\n t.is(1, substitute.bar(4))\r\n t.is(2, substitute.bar(5))\r\n})\r\n\r\n\r\ntest.skip('can stub primitive & Arg values', t => {\r\n initialize()\r\n substitute.bar(1).returns(2)\r\n substitute.bar(Arg.any()).returns(3) // throws 'substitute.bar(...).returns is not a function'\r\n t.is(5, substitute.bar(2))\r\n t.is(2, substitute.bar(1))\r\n t.is(3, substitute.bar(2))\r\n})"]} \ No newline at end of file diff --git a/dist/spec/issues/36.test.d.ts b/dist/spec/issues/36.test.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/dist/spec/issues/36.test.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/dist/spec/issues/36.test.js b/dist/spec/issues/36.test.js new file mode 100644 index 0000000..9829953 --- /dev/null +++ b/dist/spec/issues/36.test.js @@ -0,0 +1,63 @@ +"use strict"; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; +var _this = this; +Object.defineProperty(exports, "__esModule", { value: true }); +var ava_1 = require("ava"); +var index_1 = require("../../src/index"); +ava_1.default('issue 36 - promises returning object with properties', function (t) { return __awaiter(_this, void 0, void 0, function () { + var emptyFetch, now, result; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + emptyFetch = index_1.Substitute.for(); + now = new Date(); + emptyFetch.getUpdates(null).returns(Promise.resolve({ + serverCheck: now, + data: { a: [1] } + })); + return [4 /*yield*/, emptyFetch.getUpdates(null)]; + case 1: + result = _a.sent(); + t.true(result.serverCheck instanceof Date, 'given date is instanceof Date'); + t.is(result.serverCheck, now, 'dates are the same'); + t.true(Array.isArray(result.data.a), 'deep array isArray'); + t.deepEqual(result.data.a, [1], 'arrays are deep equal'); + return [2 /*return*/]; + } + }); +}); }); +//# sourceMappingURL=36.test.js.map \ No newline at end of file diff --git a/dist/spec/issues/36.test.js.map b/dist/spec/issues/36.test.js.map new file mode 100644 index 0000000..99cb5f9 --- /dev/null +++ b/dist/spec/issues/36.test.js.map @@ -0,0 +1 @@ +{"version":3,"file":"36.test.js","sourceRoot":"","sources":["../../../spec/issues/36.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iBAoBA;;AApBA,2BAAuB;AAEvB,yCAAkD;AAKlD,aAAI,CAAC,sDAAsD,EAAE,UAAM,CAAC;;;;;gBAC1D,UAAU,GAAG,kBAAU,CAAC,GAAG,EAAU,CAAC;gBACtC,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC;gBACvB,UAAU,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,CAAQ;oBACvD,WAAW,EAAE,GAAG;oBAChB,IAAI,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE;iBACnB,CAAC,CAAC,CAAC;gBACW,qBAAM,UAAU,CAAC,UAAU,CAAC,IAAI,CAAC,EAAA;;gBAA1C,MAAM,GAAG,SAAiC;gBAChD,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,WAAW,YAAY,IAAI,EAAE,+BAA+B,CAAC,CAAC;gBAC5E,CAAC,CAAC,EAAE,CAAC,MAAM,CAAC,WAAW,EAAE,GAAG,EAAE,oBAAoB,CAAC,CAAC;gBACpD,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,oBAAoB,CAAC,CAAC;gBAC3D,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,uBAAuB,CAAC,CAAC;;;;KAC5D,CAAC,CAAC","sourcesContent":["import test from 'ava';\r\n\r\nimport { Substitute, Arg } from '../../src/index';\r\n\r\ninterface IData { serverCheck: Date, data: { a: any[] } }\r\ninterface IFetch { getUpdates: (arg: Date | null) => Promise }\r\n\r\ntest('issue 36 - promises returning object with properties', async t => {\r\n const emptyFetch = Substitute.for();\r\n const now = new Date();\r\n emptyFetch.getUpdates(null).returns(Promise.resolve({\r\n serverCheck: now,\r\n data: { a: [1] }\r\n }));\r\n const result = await emptyFetch.getUpdates(null);\r\n t.true(result.serverCheck instanceof Date, 'given date is instanceof Date');\r\n t.is(result.serverCheck, now, 'dates are the same');\r\n t.true(Array.isArray(result.data.a), 'deep array isArray');\r\n t.deepEqual(result.data.a, [1], 'arrays are deep equal');\r\n});\r\n"]} \ No newline at end of file diff --git a/dist/src/Utilities.js b/dist/src/Utilities.js index 4e38d41..d7ed39a 100644 --- a/dist/src/Utilities.js +++ b/dist/src/Utilities.js @@ -19,9 +19,13 @@ function stringifyArguments(args) { exports.stringifyArguments = stringifyArguments; ; function areArgumentArraysEqual(a, b) { - for (var i = 0; i < Math.max(b.length, a.length); i++) { // @TODO should be Math.max I think -- domasx2 - if (!areArgumentsEqual(b[i], a[i])) + if (a.find(function (x) { return x instanceof Arguments_1.AllArguments; }) || b.find(function (b) { return b instanceof Arguments_1.AllArguments; })) { + return true; + } + for (var i = 0; i < Math.max(b.length, a.length); i++) { + if (!areArgumentsEqual(b[i], a[i])) { return false; + } } return true; } @@ -58,9 +62,6 @@ function areArgumentsEqual(a, b) { return a.matches(b); if (b instanceof Arguments_1.Argument) return b.matches(a); - // I think this is surprising behaviour. null !== undefined, test lib should be strict about it -- domasx2 - if ((typeof a === 'undefined' || a === null) && (typeof b === 'undefined' || b === null)) - return true; return a === b; } exports.areArgumentsEqual = areArgumentsEqual; diff --git a/dist/src/Utilities.js.map b/dist/src/Utilities.js.map index 0cd1270..e0f2d97 100644 --- a/dist/src/Utilities.js.map +++ b/dist/src/Utilities.js.map @@ -1 +1 @@ -{"version":3,"file":"Utilities.js","sourceRoot":"","sources":["../../src/Utilities.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yCAAqD;AACrD,2BAA6B;AAI7B,SAAgB,kBAAkB,CAAC,IAAW;IAC1C,IAAI,GAA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BAAQ,EAAE;QAC/C,OAAO,KAAK,CAAC;KAChB;IAED,IAAG,CAAC,YAAY,wBAAY,IAAI,CAAC,YAAY,wBAAY;QACrD,OAAO,IAAI,CAAC;IAEhB,IAAG,CAAC,YAAY,oBAAQ;QACpB,OAAO,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IAExB,IAAG,CAAC,YAAY,oBAAQ;QACpB,OAAO,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IAExB,0GAA0G;IAC1G,IAAI,CAAC,OAAO,CAAC,KAAK,WAAW,IAAI,CAAC,KAAK,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,WAAW,IAAI,CAAC,KAAK,IAAI,CAAC;QACpF,OAAO,IAAI,CAAC;IAEhB,OAAO,CAAC,KAAK,CAAC,CAAC;AACnB,CAAC;AApBD,8CAoBC;AAAA,CAAC","sourcesContent":["import { Argument, AllArguments } from \"./Arguments\";\r\nimport util = require('util')\r\n\r\nexport type Call = any[] // list of args\r\n\r\nexport function stringifyArguments(args: any[]) {\r\n args = args.map(x => util.inspect(x));\r\n return args && args.length > 0 ? 'arguments [' + args.join(', ') + ']' : 'no arguments';\r\n};\r\n\r\nexport function areArgumentArraysEqual(a: any[], b: any[]) {\r\n for(var i=0;i util.inspect(x));\r\n return args && args.length > 0 ? 'arguments [' + args.join(', ') + ']' : 'no arguments';\r\n};\r\n\r\nexport function areArgumentArraysEqual(a: any[], b: any[]) {\r\n if (a.find(x => x instanceof AllArguments) || b.find(b => b instanceof AllArguments)) {\r\n return true;\r\n }\r\n\r\n for (var i = 0; i < Math.max(b.length, a.length); i++) {\r\n if (!areArgumentsEqual(b[i], a[i])) {\r\n return false;\r\n }\r\n }\r\n\r\n return true;\r\n}\r\n\r\nexport function stringifyCalls(calls: Call[]) {\r\n\r\n if(calls.length === 0)\r\n return ' (no calls)';\r\n\r\n let output = '';\r\n for (let call of calls) {\r\n output += '\\n-> call with ' + (call.length ? stringifyArguments(call) : '(no arguments)')\r\n }\r\n\r\n return output;\r\n};\r\n\r\nexport function areArgumentsEqual(a: any, b: any) {\r\n \r\n if(a instanceof Argument && b instanceof Argument) {\r\n return false;\r\n }\r\n\r\n if(a instanceof AllArguments || b instanceof AllArguments)\r\n return true;\r\n\r\n if(a instanceof Argument) \r\n return a.matches(b);\r\n\r\n if(b instanceof Argument)\r\n return b.matches(a);\r\n\r\n return a === b;\r\n};"]} \ No newline at end of file diff --git a/dist/src/states/GetPropertyState.js.map b/dist/src/states/GetPropertyState.js.map index d76ee55..b35807f 100644 --- a/dist/src/states/GetPropertyState.js.map +++ b/dist/src/states/GetPropertyState.js.map @@ -1 +1 @@ -{"version":3,"file":"GetPropertyState.js","sourceRoot":"","sources":["../../../src/states/GetPropertyState.ts"],"names":[],"mappings":";;AAEA,iDAAgD;AAIhD,IAAM,OAAO,GAAG,MAAM,EAAE,CAAC;AAEzB;IAuBI,0BAAoB,SAAsB;QAAtB,cAAS,GAAT,SAAS,CAAa;QACtC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;QACpB,IAAI,CAAC,UAAU,GAAG,CAAC,CAAC;IACxB,CAAC;IApBD,sBAAY,wCAAU;aAAtB;YACI,OAAO,CAAC,CAAC,IAAI,CAAC,cAAc,CAAA;QAChC,CAAC;;;OAAA;IAED,sBAAW,sCAAQ;aAAnB;YACI,OAAO,IAAI,CAAC,SAAS,CAAC;QAC1B,CAAC;;;OAAA;IAED,sBAAW,uCAAS;aAApB;YACI,OAAO,IAAI,CAAC,UAAU,CAAC;QAC3B,CAAC;;;OAAA;IAED,sBAAW,2CAAa;aAAxB;YACI,OAAO,IAAI,CAAC,cAAc,CAAA;QAC9B,CAAC;;;OAAA;IAQD,gCAAK,GAAL,UAAM,OAAgB,EAAE,IAAW;QAC/B,IAAI,CAAC,UAAU,GAAG,CAAC,CAAC;QAEpB,IAAI,IAAI,CAAC,aAAa,EAAE;YACpB,OAAO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ACvB,KAAI,CAAC,UAAU,EAAE,CAAC;gBAElB,OAAO,CAAC,KAAK,GAAG,OAAO,CAAC,YAAY,CAAC;YACzC,CAAC,CAAC;SACL;QAED,IAAG,CAAC,eAAe,EAAE;YACjB,IAAI,CAAC,UAAU,EAAE,CAAC;YAElB,IAAG,IAAI,CAAC,OAAO;gBACX,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;YAE5C,IAAG,IAAI,CAAC,OAAO,KAAK,OAAO,EAAE;gBACzB,IAAI,YAAY,GAAG,IAAI,CAAC,OAAgB,CAAC;gBACzC,IAAG,YAAY,CAAC,MAAM,KAAK,CAAC;oBACxB,OAAO,YAAY,CAAC,CAAC,CAAC,CAAC;gBAE3B,OAAO,YAAY,CAAC,IAAI,CAAC,UAAU,GAAC,CAAC,CAAC,CAAC;aAC1C;SACJ;QAED,OAAO,CAAC,YAAY,CAAC,kCAAkC,CACnD,CAAC,EAAE,CAAC,EAAG,8CAA8C;QACrD,IAAI,CAAC,SAAS,EACd,UAAU,EACV,IAAI,CAAC,QAAQ,EACb,EAAE,CAAC,CAAC;QAER,OAAO,OAAO,CAAC,KAAK,CAAC;IACzB,CAAC;IACL,uBAAC;AAAD,CAAC,AArGD,IAqGC;AArGY,4CAAgB","sourcesContent":["import { ContextState, PropertyKey } from \"./ContextState\";\r\nimport { Context } from \"src/Context\";\r\nimport { FunctionState } from \"./FunctionState\";\r\nimport { areArgumentsEqual, areArgumentArraysEqual } from \"../Utilities\";\r\nimport { Arg } from \"../Arguments\";\r\n\r\nconst Nothing = Symbol();\r\n\r\nexport class GetPropertyState implements ContextState {\r\n private returns: any[]|Symbol;\r\n private mimicks: Function|null;\r\n\r\n private _callCount: number;\r\n private _functionState?: FunctionState;\r\n\r\n private get isFunction(): boolean {\r\n return !!this._functionState\r\n }\r\n\r\n public get property() {\r\n return this._property;\r\n }\r\n\r\n public get callCount() {\r\n return this._callCount;\r\n }\r\n\r\n public get functionState(): FunctionState | undefined {\r\n return this._functionState\r\n }\r\n\r\n constructor(private _property: PropertyKey) {\r\n this.returns = Nothing;\r\n this.mimicks = null;\r\n this._callCount = 0;\r\n }\r\n\r\n apply(context: Context, args: any[]) {\r\n this._callCount = 0;\r\n\r\n if (this.functionState) {\r\n context.state = this.functionState\r\n return this.functionState.apply(context, args);\r\n }\r\n\r\n var functionState = new FunctionState(this);\r\n context.state = functionState;\r\n this._functionState = functionState\r\n\r\n return context.apply(args);\r\n }\r\n\r\n set(context: Context, property: PropertyKey, value: any) {\r\n }\r\n\r\n get(context: Context, property: PropertyKey) {\r\n const hasExpectations = context.initialState.hasExpectations;\r\n\r\n if (property === 'then')\r\n return void 0;\r\n\r\n if(this.isFunction)\r\n return context.proxy;\r\n\r\n if(property === 'mimicks') {\r\n return (input: Function) => {\r\n this.mimicks = input;\r\n this._callCount--;\r\n\r\n context.state = context.initialState;\r\n }\r\n }\r\n\r\n if(property === 'returns') {\r\n if(this.returns !== Nothing)\r\n throw new Error('The return value for the property ' + this._property.toString() + ' has already been set to ' + this.returns);\r\n\r\n return (...returns: any[]) => {\r\n this.returns = returns;\r\n this._callCount--;\r\n\r\n context.state = context.initialState;\r\n };\r\n }\r\n\r\n if(!hasExpectations) {\r\n this._callCount++;\r\n\r\n if(this.mimicks)\r\n return this.mimicks.apply(this.mimicks);\r\n\r\n if(this.returns !== Nothing) {\r\n var returnsArray = this.returns as any[];\r\n if(returnsArray.length === 1)\r\n return returnsArray[0];\r\n \r\n return returnsArray[this._callCount-1];\r\n }\r\n }\r\n\r\n context.initialState.assertCallCountMatchesExpectations(\r\n [[]], // I'm not sure what this was supposed to mean\r\n this.callCount,\r\n 'property',\r\n this.property,\r\n []);\r\n\r\n return context.proxy;\r\n }\r\n}"]} \ No newline at end of file +{"version":3,"file":"GetPropertyState.js","sourceRoot":"","sources":["../../../src/states/GetPropertyState.ts"],"names":[],"mappings":";;AAEA,iDAAgD;AAEhD,IAAM,OAAO,GAAG,MAAM,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;aAC1C;SACJ;QAED,OAAO,CAAC,YAAY,CAAC,kCAAkC,CACnD,CAAC,EAAE,CAAC,EAAG,8CAA8C;QACrD,IAAI,CAAC,SAAS,EACd,UAAU,EACV,IAAI,CAAC,QAAQ,EACb,EAAE,CAAC,CAAC;QAER,OAAO,OAAO,CAAC,KAAK,CAAC;IACzB,CAAC;IACL,uBAAC;AAAD,CAAC,AArGD,IAqGC;AArGY,4CAAgB","sourcesContent":["import { ContextState, PropertyKey } from \"./ContextState\";\r\nimport { Context } from \"src/Context\";\r\nimport { FunctionState } from \"./FunctionState\";\r\n\r\nconst Nothing = Symbol();\r\n\r\nexport class GetPropertyState implements ContextState {\r\n private returns: any[]|Symbol;\r\n private mimicks: Function|null;\r\n\r\n private _callCount: number;\r\n private _functionState?: FunctionState;\r\n\r\n private get isFunction(): boolean {\r\n return !!this._functionState\r\n }\r\n\r\n public get property() {\r\n return this._property;\r\n }\r\n\r\n public get callCount() {\r\n return this._callCount;\r\n }\r\n\r\n public get functionState(): FunctionState | undefined {\r\n return this._functionState\r\n }\r\n\r\n constructor(private _property: PropertyKey) {\r\n this.returns = Nothing;\r\n this.mimicks = null;\r\n this._callCount = 0;\r\n }\r\n\r\n apply(context: Context, args: any[]) {\r\n this._callCount = 0;\r\n\r\n if (this.functionState) {\r\n context.state = this.functionState\r\n return this.functionState.apply(context, args);\r\n }\r\n\r\n var functionState = new FunctionState(this);\r\n context.state = functionState;\r\n this._functionState = functionState\r\n\r\n return context.apply(args);\r\n }\r\n\r\n set(context: Context, property: PropertyKey, value: any) {\r\n }\r\n\r\n get(context: Context, property: PropertyKey) {\r\n const hasExpectations = context.initialState.hasExpectations;\r\n\r\n if (property === 'then')\r\n return void 0;\r\n\r\n if(this.isFunction)\r\n return context.proxy;\r\n\r\n if(property === 'mimicks') {\r\n return (input: Function) => {\r\n this.mimicks = input;\r\n this._callCount--;\r\n\r\n context.state = context.initialState;\r\n }\r\n }\r\n\r\n if(property === 'returns') {\r\n if(this.returns !== Nothing)\r\n throw new Error('The return value for the property ' + this._property.toString() + ' has already been set to ' + this.returns);\r\n\r\n return (...returns: any[]) => {\r\n this.returns = returns;\r\n this._callCount--;\r\n\r\n context.state = context.initialState;\r\n };\r\n }\r\n\r\n if(!hasExpectations) {\r\n this._callCount++;\r\n\r\n if(this.mimicks)\r\n return this.mimicks.apply(this.mimicks);\r\n\r\n if(this.returns !== Nothing) {\r\n var returnsArray = this.returns as any[];\r\n if(returnsArray.length === 1)\r\n return returnsArray[0];\r\n \r\n return returnsArray[this._callCount-1];\r\n }\r\n }\r\n\r\n context.initialState.assertCallCountMatchesExpectations(\r\n [[]], // I'm not sure what this was supposed to mean\r\n this.callCount,\r\n 'property',\r\n this.property,\r\n []);\r\n\r\n return context.proxy;\r\n }\r\n}"]} \ No newline at end of file diff --git a/dist/src/states/SetPropertyState.js.map b/dist/src/states/SetPropertyState.js.map index c6727bb..0469658 100644 --- a/dist/src/states/SetPropertyState.js.map +++ b/dist/src/states/SetPropertyState.js.map @@ -1 +1 @@ -{"version":3,"file":"SetPropertyState.js","sourceRoot":"","sources":["../../../src/states/SetPropertyState.ts"],"names":[],"mappings":";;AAEA,0CAAqE;AAErE,IAAM,OAAO,GAAG,MAAM,EAAE,CAAC;AAEzB;IAgBI,0BAAoB,SAAsB;QAAE,cAAc;aAAd,UAAc,EAAd,qBAAc,EAAd,IAAc;YAAd,6BAAc;;QAAtC,cAAS,GAAT,SAAS,CAAa;QACtC,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC;QAEvB,IAAI,CAAC,UAAU,GAAG,CAAC,CAAC;IACxB,CAAC;IAhBD,sBAAW,uCAAS;aAApB;YACI,OAAO,IAAI,CAAC,UAAU,CAAC;QAC3B,CAAC;;;OAAA;IAED,sBAAW,sCAAQ;aAAnB;YACI,OAAO,IAAI,CAAC,SAAS,CAAC;QAC1B,CAAC;;;OAAA;IAED,sBAAW,uCAAS;aAApB;YACI,OAAO,IAAI,CAAC,UAAU,CAAC;QAC3B,CAAC;;;OAAA;IAQD,gCAAK,GAAL,UAAM,OAAgB;QAClB,OAAO,KAAK,CAAC,CAAC;IAClB,CAAC;IAED,8BAAG,GAAH,UAAI,OAAgB,EAAE,QAAqB,EAAE,KAAU;QACnD,IAAI,SAAS,GAAG,IAAI,CAAC,UAAU,CAAC;QAChC,IAAM,eAAe,GAAG,OAAO,CAAC,YAAY,CAAC,eAAe,CAAC;QAC7D,IAAG,eAAe,EAAE;YAChB,SAAS,GAAG,OAAO,CAAC,YAAY;iBAC3B,iBAAiB;iBACjB,MAAM,CAAC,UAAA,CAAC,IAAI,OAAA,6BAAiB,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,EAAxC,CAAwC,CAAC;iBACrD,GAAG,CAAC,UAAA,CAAC,IAAI,OAAA,CAAC,CAAC,UAAU,EAAZ,CAAY,CAAC;iBACtB,MAAM,CAAC,UAAC,CAAC,EAAE,CAAC,IAAK,OAAA,CAAC,GAAG,CAAC,EAAL,CAAK,EAAE,CAAC,CAAC,CAAC;SACnC;QAED,OAAO,CAAC,YAAY,CAAC,kCAAkC,CACnD,CAAC,EAAE,CAAC,EAAE,wCAAwC;QAC9C,SAAS,EACT,UAAU,EACV,IAAI,CAAC,QAAQ,EACb,IAAI,CAAC,SAAS,CAAC,CAAC;QAEpB,IAAG,CAAC,eAAe,EAAE;YACjB,IAAI,CAAC,UAAU,EAAE,CAAC;SACrB;IACL,CAAC;IAED,8BAAG,GAAH,UAAI,OAAgB,EAAE,QAAqB;QACvC,OAAO,KAAK,CAAC,CAAC;IAClB,CAAC;IACL,uBAAC;AAAD,CAAC,AApDD,IAoDC;AApDY,4CAAgB","sourcesContent":["import { ContextState, PropertyKey } from \"./ContextState\";\r\nimport { Context } from \"src/Context\";\r\nimport { stringifyArguments, areArgumentsEqual } from \"../Utilities\";\r\n\r\nconst Nothing = Symbol();\r\n\r\nexport class SetPropertyState implements ContextState {\r\n private _callCount: number;\r\n private _arguments: any[];\r\n\r\n public get arguments() {\r\n return this._arguments;\r\n }\r\n\r\n public get property() {\r\n return this._property;\r\n }\r\n\r\n public get callCount() {\r\n return this._callCount;\r\n }\r\n\r\n constructor(private _property: PropertyKey, ...args: any[]) {\r\n this._arguments = args;\r\n\r\n this._callCount = 0;\r\n }\r\n\r\n apply(context: Context): undefined {\r\n return void 0;\r\n }\r\n\r\n set(context: Context, property: PropertyKey, value: any) {\r\n let callCount = this._callCount;\r\n const hasExpectations = context.initialState.hasExpectations;\r\n if(hasExpectations) {\r\n callCount = context.initialState\r\n .setPropertyStates\r\n .filter(x => areArgumentsEqual(x.arguments[0], value))\r\n .map(x => x._callCount)\r\n .reduce((a, b) => a + b, 0);\r\n }\r\n\r\n context.initialState.assertCallCountMatchesExpectations(\r\n [[]], // not sure what this was supposed to do\r\n callCount,\r\n 'property',\r\n this.property,\r\n this.arguments);\r\n\r\n if(!hasExpectations) {\r\n this._callCount++;\r\n }\r\n }\r\n\r\n get(context: Context, property: PropertyKey): undefined {\r\n return void 0;\r\n }\r\n}"]} \ No newline at end of file +{"version":3,"file":"SetPropertyState.js","sourceRoot":"","sources":["../../../src/states/SetPropertyState.ts"],"names":[],"mappings":";;AAEA,0CAAiD;AAEjD,IAAM,OAAO,GAAG,MAAM,EAAE,CAAC;AAEzB;IAgBI,0BAAoB,SAAsB;QAAE,cAAc;aAAd,UAAc,EAAd,qBAAc,EAAd,IAAc;YAAd,6BAAc;;QAAtC,cAAS,GAAT,SAAS,CAAa;QACtC,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC;QAEvB,IAAI,CAAC,UAAU,GAAG,CAAC,CAAC;IACxB,CAAC;IAhBD,sBAAW,uCAAS;aAApB;YACI,OAAO,IAAI,CAAC,UAAU,CAAC;QAC3B,CAAC;;;OAAA;IAED,sBAAW,sCAAQ;aAAnB;YACI,OAAO,IAAI,CAAC,SAAS,CAAC;QAC1B,CAAC;;;OAAA;IAED,sBAAW,uCAAS;aAApB;YACI,OAAO,IAAI,CAAC,UAAU,CAAC;QAC3B,CAAC;;;OAAA;IAQD,gCAAK,GAAL,UAAM,OAAgB;QAClB,OAAO,KAAK,CAAC,CAAC;IAClB,CAAC;IAED,8BAAG,GAAH,UAAI,OAAgB,EAAE,QAAqB,EAAE,KAAU;QACnD,IAAI,SAAS,GAAG,IAAI,CAAC,UAAU,CAAC;QAChC,IAAM,eAAe,GAAG,OAAO,CAAC,YAAY,CAAC,eAAe,CAAC;QAC7D,IAAG,eAAe,EAAE;YAChB,SAAS,GAAG,OAAO,CAAC,YAAY;iBAC3B,iBAAiB;iBACjB,MAAM,CAAC,UAAA,CAAC,IAAI,OAAA,6BAAiB,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,EAAxC,CAAwC,CAAC;iBACrD,GAAG,CAAC,UAAA,CAAC,IAAI,OAAA,CAAC,CAAC,UAAU,EAAZ,CAAY,CAAC;iBACtB,MAAM,CAAC,UAAC,CAAC,EAAE,CAAC,IAAK,OAAA,CAAC,GAAG,CAAC,EAAL,CAAK,EAAE,CAAC,CAAC,CAAC;SACnC;QAED,OAAO,CAAC,YAAY,CAAC,kCAAkC,CACnD,CAAC,EAAE,CAAC,EAAE,wCAAwC;QAC9C,SAAS,EACT,UAAU,EACV,IAAI,CAAC,QAAQ,EACb,IAAI,CAAC,SAAS,CAAC,CAAC;QAEpB,IAAG,CAAC,eAAe,EAAE;YACjB,IAAI,CAAC,UAAU,EAAE,CAAC;SACrB;IACL,CAAC;IAED,8BAAG,GAAH,UAAI,OAAgB,EAAE,QAAqB;QACvC,OAAO,KAAK,CAAC,CAAC;IAClB,CAAC;IACL,uBAAC;AAAD,CAAC,AApDD,IAoDC;AApDY,4CAAgB","sourcesContent":["import { ContextState, PropertyKey } from \"./ContextState\";\r\nimport { Context } from \"src/Context\";\r\nimport { areArgumentsEqual } from \"../Utilities\";\r\n\r\nconst Nothing = Symbol();\r\n\r\nexport class SetPropertyState implements ContextState {\r\n private _callCount: number;\r\n private _arguments: any[];\r\n\r\n public get arguments() {\r\n return this._arguments;\r\n }\r\n\r\n public get property() {\r\n return this._property;\r\n }\r\n\r\n public get callCount() {\r\n return this._callCount;\r\n }\r\n\r\n constructor(private _property: PropertyKey, ...args: any[]) {\r\n this._arguments = args;\r\n\r\n this._callCount = 0;\r\n }\r\n\r\n apply(context: Context): undefined {\r\n return void 0;\r\n }\r\n\r\n set(context: Context, property: PropertyKey, value: any) {\r\n let callCount = this._callCount;\r\n const hasExpectations = context.initialState.hasExpectations;\r\n if(hasExpectations) {\r\n callCount = context.initialState\r\n .setPropertyStates\r\n .filter(x => areArgumentsEqual(x.arguments[0], value))\r\n .map(x => x._callCount)\r\n .reduce((a, b) => a + b, 0);\r\n }\r\n\r\n context.initialState.assertCallCountMatchesExpectations(\r\n [[]], // not sure what this was supposed to do\r\n callCount,\r\n 'property',\r\n this.property,\r\n this.arguments);\r\n\r\n if(!hasExpectations) {\r\n this._callCount++;\r\n }\r\n }\r\n\r\n get(context: Context, property: PropertyKey): undefined {\r\n return void 0;\r\n }\r\n}"]} \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 31db5b3..2179847 100644 --- a/package-lock.json +++ b/package-lock.json @@ -399,9 +399,9 @@ } }, "@types/node": { - "version": "11.12.1", - "resolved": "https://registry.npmjs.org/@types/node/-/node-11.12.1.tgz", - "integrity": "sha512-sKDlqv6COJrR7ar0+GqqhrXQDzQlMcqMnF2iEU6m9hLo8kxozoAGUazwPyELHlRVmjsbvlnGXjnzyptSXVmceA==", + "version": "11.13.7", + "resolved": "https://registry.npmjs.org/@types/node/-/node-11.13.7.tgz", + "integrity": "sha512-suFHr6hcA9mp8vFrZTgrmqW2ZU3mbWsryQtQlY/QvwTISCw7nw/j+bCQPPohqmskhmqa5wLNuMHTTsc+xf1MQg==", "dev": true }, "ansi-align": { diff --git a/spec/Utilities.spec.ts b/spec/Utilities.spec.ts new file mode 100644 index 0000000..9a14382 --- /dev/null +++ b/spec/Utilities.spec.ts @@ -0,0 +1,85 @@ +import test from 'ava'; +import { areArgumentArraysEqual } from '../src/Utilities'; +import { Arg } from '../src/index'; + +const testObject = { "foo": "bar" }; +const testArray = ["a", 1, true]; +const testFunc = () => {}; + +//#region areArgumentArraysEqual +test('areArgumentArraysEqual should return valid result for primitive arguments', t => { + // single + t.true(areArgumentArraysEqual([''],[''])); + t.true(areArgumentArraysEqual(['a'],['a'])); + t.true(areArgumentArraysEqual([0],[0])); + t.true(areArgumentArraysEqual([1],[1])); + t.true(areArgumentArraysEqual([true],[true])); + t.true(areArgumentArraysEqual([false],[false])); + t.true(areArgumentArraysEqual([undefined],[undefined])); + t.true(areArgumentArraysEqual([null],[null])); + t.true(areArgumentArraysEqual([testObject],[testObject])); + t.true(areArgumentArraysEqual([testArray],[testArray])); + t.true(areArgumentArraysEqual([testFunc],[testFunc])); + + t.false(areArgumentArraysEqual(['a'],['b'])); + t.false(areArgumentArraysEqual([1],[2])); + t.false(areArgumentArraysEqual([true],[false])); + t.false(areArgumentArraysEqual([undefined],[null])); + t.false(areArgumentArraysEqual([testObject],[testArray])); + + // multi + t.true(areArgumentArraysEqual([1,2,3], [1,2,3])); + + t.false(areArgumentArraysEqual([1,2,3], [3,2,1])); + t.false(areArgumentArraysEqual([1,2,3,4], [1,2,3])); + t.false(areArgumentArraysEqual([1,2,3], [1,2,3,4])); +}) + +test('areArgumentArraysEqual should return valid result using Arg.all()', t => { + t.true(areArgumentArraysEqual([Arg.all()],[])); + t.true(areArgumentArraysEqual([Arg.all()],[0])); + t.true(areArgumentArraysEqual([Arg.all()],[1])); + t.true(areArgumentArraysEqual([Arg.all()],['string'])); + t.true(areArgumentArraysEqual([Arg.all()],[true])); + t.true(areArgumentArraysEqual([Arg.all()],[false])); + t.true(areArgumentArraysEqual([Arg.all()],[null])); + t.true(areArgumentArraysEqual([Arg.all()],[undefined])); + t.true(areArgumentArraysEqual([Arg.all()],[1,2])); + t.true(areArgumentArraysEqual([Arg.all()],['string1', 'string2'])); +}) + +test('areArgumentArraysEqual should return valid result using Arg.any()', t => { + t.true(areArgumentArraysEqual([Arg.any()], ['hi'])); + t.true(areArgumentArraysEqual([Arg.any()], [1])); + t.true(areArgumentArraysEqual([Arg.any()], [0])); + t.true(areArgumentArraysEqual([Arg.any()], [false])); + t.true(areArgumentArraysEqual([Arg.any()], [true])); + t.true(areArgumentArraysEqual([Arg.any()], [null])); + t.true(areArgumentArraysEqual([Arg.any()], [undefined])); + t.true(areArgumentArraysEqual([Arg.any()], [testObject])); + t.true(areArgumentArraysEqual([Arg.any()], [testArray])); + t.true(areArgumentArraysEqual([Arg.any()], [testFunc])); + t.true(areArgumentArraysEqual([Arg.any()], [])); + + t.true(areArgumentArraysEqual([Arg.any('string')], ['foo'])); + t.true(areArgumentArraysEqual([Arg.any('number')], [1])); + t.true(areArgumentArraysEqual([Arg.any('boolean')], [true])); + t.true(areArgumentArraysEqual([Arg.any('object')], [testObject])); + t.true(areArgumentArraysEqual([Arg.any('array')], [testArray])); + t.true(areArgumentArraysEqual([Arg.any('function')], [testFunc])); + + t.false(areArgumentArraysEqual([Arg.any('string')], [1])); + t.false(areArgumentArraysEqual([Arg.any('number')], ['string'])); + t.false(areArgumentArraysEqual([Arg.any('boolean')], [null])); + t.false(areArgumentArraysEqual([Arg.any('object')], ['foo'])); + t.false(areArgumentArraysEqual([Arg.any('array')], ['bar'])); + t.false(areArgumentArraysEqual([Arg.any('function')], ['foo'])); +}) + +test('areArgumentArraysEqual should return valid result using Arg.is()', t => { + t.true(areArgumentArraysEqual([Arg.is(x => x === 'foo')], ['foo'])); + t.true(areArgumentArraysEqual([Arg.is(x => x % 2 == 0)], [4])); + + t.false(areArgumentArraysEqual([Arg.is(x => x === 'foo')], ['bar'])); + t.false(areArgumentArraysEqual([Arg.is(x => x % 2 == 0)], [3])); +}); \ No newline at end of file diff --git a/spec/index.test.ts b/spec/index.test.ts index edbdfd4..b75841d 100644 --- a/spec/index.test.ts +++ b/spec/index.test.ts @@ -1,7 +1,6 @@ import test from 'ava'; import { Substitute, Arg } from '../src/index'; -import { areArgumentsEqual } from '../src/Utilities'; import { OmitProxyMethods, ObjectSubstitute } from '../src/Transformations'; class Dummy { @@ -238,16 +237,6 @@ test('partial mocks using property instance mimicks', t => { t.deepEqual(substitute.d, 1337); }); -test('are arguments equal', t => { - initialize(); - - t.true(areArgumentsEqual(Arg.any(), 'hi')); - t.true(areArgumentsEqual(Arg.any('array'), ['foo', 'bar'])); - - t.false(areArgumentsEqual(['foo', 'bar'], ['foo', 'bar'])); - t.false(areArgumentsEqual(Arg.any('array'), 1337)); -}); - test('verifying with more arguments fails', t => { initialize() substitute.bar(1) diff --git a/src/Utilities.ts b/src/Utilities.ts index 58896c7..ca412b9 100644 --- a/src/Utilities.ts +++ b/src/Utilities.ts @@ -9,9 +9,14 @@ export function stringifyArguments(args: any[]) { }; export function areArgumentArraysEqual(a: any[], b: any[]) { - for(var i=0;i x instanceof AllArguments) || b.find(b => b instanceof AllArguments)) { + return true; + } + + for (var i = 0; i < Math.max(b.length, a.length); i++) { + if (!areArgumentsEqual(b[i], a[i])) { return false; + } } return true; @@ -45,9 +50,5 @@ export function areArgumentsEqual(a: any, b: any) { if(b instanceof Argument) return b.matches(a); - // I think this is surprising behaviour. null !== undefined, test lib should be strict about it -- domasx2 - if ((typeof a === 'undefined' || a === null) && (typeof b === 'undefined' || b === null)) - return true; - return a === b; }; \ No newline at end of file diff --git a/src/states/GetPropertyState.ts b/src/states/GetPropertyState.ts index ee89cf8..ddf8b15 100644 --- a/src/states/GetPropertyState.ts +++ b/src/states/GetPropertyState.ts @@ -1,8 +1,6 @@ import { ContextState, PropertyKey } from "./ContextState"; import { Context } from "src/Context"; import { FunctionState } from "./FunctionState"; -import { areArgumentsEqual, areArgumentArraysEqual } from "../Utilities"; -import { Arg } from "../Arguments"; const Nothing = Symbol(); diff --git a/src/states/SetPropertyState.ts b/src/states/SetPropertyState.ts index 591ca09..0ce3f9a 100644 --- a/src/states/SetPropertyState.ts +++ b/src/states/SetPropertyState.ts @@ -1,6 +1,6 @@ import { ContextState, PropertyKey } from "./ContextState"; import { Context } from "src/Context"; -import { stringifyArguments, areArgumentsEqual } from "../Utilities"; +import { areArgumentsEqual } from "../Utilities"; const Nothing = Symbol();