From 8125ae80d8c01c7fe3304894395d33f63e0a6333 Mon Sep 17 00:00:00 2001 From: George Cook Date: Mon, 9 May 2022 18:00:45 +0200 Subject: [PATCH] Feat/update to bsc 0.49.0 (#167) * bump * update to bsc 0.49.0 * fixes tests --- bsc-plugin/CHANGELOG.md | 8 ++ bsc-plugin/package.json | 4 +- bsc-plugin/src/plugin.spec.ts | 98 ++++++++++++------------ framework/src/source/BaseTestSuite.bs | 9 +++ tests/src/source/NewExpectSyntax.spec.bs | 1 + 5 files changed, 69 insertions(+), 51 deletions(-) diff --git a/bsc-plugin/CHANGELOG.md b/bsc-plugin/CHANGELOG.md index a044c6b6..d8a2f07b 100644 --- a/bsc-plugin/CHANGELOG.md +++ b/bsc-plugin/CHANGELOG.md @@ -4,8 +4,16 @@ All notable changes to this project will be documented in this file. Dates are d Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). +#### [4.8.0](https://github.com/georgejecook/rooibos/compare/4.7.0...4.8.0) + +- adds expectLastCallToThrowError so we can throw errors from fakes [`#166`](https://github.com/georgejecook/rooibos/pull/166) +- Quality of life fixes [`#162`](https://github.com/georgejecook/rooibos/pull/162) +- bump [`b04ee37`](https://github.com/georgejecook/rooibos/commit/b04ee37e6f3eb2a0d5929200b8ffb47755564eb0) + #### [4.7.0](https://github.com/georgejecook/rooibos/compare/4.6.1...4.7.0) +> 2 April 2022 + - Feature/accept expect once with function param [`#157`](https://github.com/georgejecook/rooibos/pull/157) - adds callfunc once method [`#156`](https://github.com/georgejecook/rooibos/pull/156) - Update slack link [`#155`](https://github.com/georgejecook/rooibos/pull/155) diff --git a/bsc-plugin/package.json b/bsc-plugin/package.json index 1a40d3ca..c5d25ba5 100644 --- a/bsc-plugin/package.json +++ b/bsc-plugin/package.json @@ -1,6 +1,6 @@ { "name": "rooibos-roku", - "version": "4.7.0", + "version": "4.8.0", "description": "simple, flexible, fun brightscript test framework for roku scenegraph apps - roku brighterscript plugin", "repository": { "type": "git", @@ -26,7 +26,7 @@ "@types/node": "^17.0.29", "@typescript-eslint/eslint-plugin": "^4.4.1", "@typescript-eslint/parser": "^4.4.1", - "brighterscript": "0.45.3", + "brighterscript": "0.49.0", "chai": "^4.2.0", "chai-subset": "^1.6.0", "coveralls": "^3.0.0", diff --git a/bsc-plugin/src/plugin.spec.ts b/bsc-plugin/src/plugin.spec.ts index 2ef183fa..315a1c63 100644 --- a/bsc-plugin/src/plugin.spec.ts +++ b/bsc-plugin/src/plugin.spec.ts @@ -348,51 +348,51 @@ describe('RooibosPlugin', () => { instance.super0_getTestSuiteData = instance.getTestSuiteData instance.getTestSuiteData = function() return { - name: "ATest", - isSolo: false, - noCatch: false, - isIgnored: false, - pkgPath: "${s`source/test.spec.bs`}", - filePath: "${s`${tmpPath}/rootDir/source/test.spec.bs`}", - lineNumber: 3, - valid: true, - hasFailures: false, - hasSoloTests: false, - hasIgnoredTests: false, - hasSoloGroups: false, - setupFunctionName: "", - tearDownFunctionName: "", - beforeEachFunctionName: "", - afterEachFunctionName: "", - isNodeTest: false, - nodeName: "", - generatedNodeName: "ATest", + name: "ATest" + isSolo: false + noCatch: false + isIgnored: false + pkgPath: "${s`source/test.spec.bs`}" + filePath: "${s`${tmpPath}/rootDir/source/test.spec.bs`}" + lineNumber: 3 + valid: true + hasFailures: false + hasSoloTests: false + hasIgnoredTests: false + hasSoloGroups: false + setupFunctionName: "" + tearDownFunctionName: "" + beforeEachFunctionName: "" + afterEachFunctionName: "" + isNodeTest: false + nodeName: "" + generatedNodeName: "ATest" testGroups: [ { - name: "groupA", - isSolo: false, - isIgnored: false, - filename: "${s`source/test.spec.bs`}", - lineNumber: "3", - setupFunctionName: "", - tearDownFunctionName: "", - beforeEachFunctionName: "", - afterEachFunctionName: "", + name: "groupA" + isSolo: false + isIgnored: false + filename: "${s`source/test.spec.bs`}" + lineNumber: "3" + setupFunctionName: "" + tearDownFunctionName: "" + beforeEachFunctionName: "" + afterEachFunctionName: "" testCases: [ { - isSolo: false, - noCatch: false, - funcName: "groupA_is_test1", - isIgnored: false, - isParamTest: false, - name: "is test1", - lineNumber: 7, - paramLineNumber: 0, - assertIndex: 0, - assertLineNumberMap: {}, - rawParams: invalid, - paramTestIndex: 0, - expectedNumberOfParams: 0, + isSolo: false + noCatch: false + funcName: "groupA_is_test1" + isIgnored: false + isParamTest: false + name: "is test1" + lineNumber: 7 + paramLineNumber: 0 + assertIndex: 0 + assertLineNumberMap: {} + rawParams: invalid + paramTestIndex: 0 + expectedNumberOfParams: 0 isParamsValid: true } ] @@ -480,8 +480,8 @@ describe('RooibosPlugin', () => { m.currentAssertLineNumber = 8 m._expectCalled(m.thing, "callFunc", [ - "getFunction", - "a", + "getFunction" + "a" "b" ]) if m.currentResult.isFail then return invalid @@ -489,8 +489,8 @@ describe('RooibosPlugin', () => { m.currentAssertLineNumber = 9 m._expectCalled(m.thing, "callFunc", [ - "getFunction", - "a", + "getFunction" + "a" "b" ], "return") if m.currentResult.isFail then return invalid @@ -560,7 +560,7 @@ describe('RooibosPlugin', () => { m.currentAssertLineNumber = 8 m._expectCalled(m.thing, "getFunction", [ - "arg1", + "arg1" "arg2" ]) if m.currentResult.isFail then return invalid @@ -568,7 +568,7 @@ describe('RooibosPlugin', () => { m.currentAssertLineNumber = 9 m._expectCalled(m.thing, "getFunction", [ - "arg1", + "arg1" "arg2" ], "return") if m.currentResult.isFail then return invalid @@ -613,7 +613,7 @@ describe('RooibosPlugin', () => { m.currentAssertLineNumber = 9 m._expectCalled(item, "getFunction", [ - "arg1", + "arg1" "arg2" ]) if m.currentResult.isFail then return invalid @@ -621,7 +621,7 @@ describe('RooibosPlugin', () => { m.currentAssertLineNumber = 10 m._expectCalled(item, "getFunction", [ - "arg1", + "arg1" "arg2" ], "return") if m.currentResult.isFail then return invalid diff --git a/framework/src/source/BaseTestSuite.bs b/framework/src/source/BaseTestSuite.bs index bb25dba3..88089c31 100644 --- a/framework/src/source/BaseTestSuite.bs +++ b/framework/src/source/BaseTestSuite.bs @@ -1603,6 +1603,15 @@ namespace rooibos return fake end function + function expectLastCallToThrowError(error as dynamic) + try + mock = m.mocks[m.__mockId.toStr()] + mock.toThrow(error) + catch error + m.log.error("could not add throw to last call", error) + end try + end function + function expectCalled(invocation as dynamic, returnValue = invalid as dynamic, thrownError = invalid as dynamic) as object 'mock function body - the plugin replaces this return invalid diff --git a/tests/src/source/NewExpectSyntax.spec.bs b/tests/src/source/NewExpectSyntax.spec.bs index 3e81f8bf..ff0c69f7 100644 --- a/tests/src/source/NewExpectSyntax.spec.bs +++ b/tests/src/source/NewExpectSyntax.spec.bs @@ -1,5 +1,6 @@ namespace tests + @only @suite class NewExpectSyntaxTests extends rooibos.BaseTestSuite