Skip to content

Commit

Permalink
Merge pull request #297 from FlowFuse/fix-tests-070
Browse files Browse the repository at this point in the history
Fix tests after we no longer use node._msg
  • Loading branch information
joepavitt authored Oct 24, 2023
2 parents 37429c9 + d0027fc commit 50d902a
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 8 deletions.
8 changes: 8 additions & 0 deletions nodes/config/ui_base.js
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,14 @@ module.exports = function (RED) {
node.ui.widgets.set(widget.id, widget)
}

/**
* Helper Function for testing
*/

widgetNode.getState = function () {
return datastore.get(widgetNode.id)
}

/**
* Event Handlers
*/
Expand Down
1 change: 0 additions & 1 deletion test/nodes/widgets/ui_button.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ describe('ui-button node', function () {

// add a fake connection so that button has somewhere to emit to and we can spy on it
base.uiShared.connections['fake-conn-id'] = socket
base.connections['fake-conn-id'] = socket

// now send a message to the node
const button = helper.getNode('node-ui-button')
Expand Down
2 changes: 1 addition & 1 deletion test/nodes/widgets/ui_dropdown.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ describe('ui-dropdown node', function () {
const helperAfterComplete = helper.getNode('helper-node-complete')
helperAfterComplete.on('input', (msg) => {
try {
dNode._msg.payload.should.equal(msg.payload)
dNode.getState().payload.should.equal(msg.payload)
msgSent.should.be.false()
resolve()
} catch (err) {
Expand Down
2 changes: 1 addition & 1 deletion test/nodes/widgets/ui_slider.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ describe('ui-slider node', function () {
const helperAfterComplete = helper.getNode('helper-node-complete')
helperAfterComplete.on('input', (msg) => {
try {
sNode._msg.payload.should.equal(msg.payload)
sNode.getState().payload.should.equal(msg.payload)
msgSent.should.be.false()
resolve()
} catch (err) {
Expand Down
7 changes: 3 additions & 4 deletions test/nodes/widgets/ui_switch.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ describe('ui-switch node', function () {
const hNode = helper.getNode('helper-node')
hNode.on('input', (msg) => {
try {
sNode._msg.payload.should.equal(msg.payload)
sNode.getState().payload.should.equal(msg.payload)
resolve()
} catch (err) {
reject(err)
Expand All @@ -141,7 +141,7 @@ describe('ui-switch node', function () {
// we need to be sure that the helperAfterSwitch node has run first
setTimeout(() => {
try {
sNode._msg.payload.should.equal(msg.payload)
sNode.getState().payload.should.equal(msg.payload)
msgSent.should.be.true()
resolve()
} catch (err) {
Expand Down Expand Up @@ -173,7 +173,6 @@ describe('ui-switch node', function () {
// we need to be sure that the helperAfterSwitch node has run first
setTimeout(() => {
try {
(sNode._msg === undefined).should.be.true()
sNode.warn.should.be.called()
msgSent.should.be.false()
resolve()
Expand Down Expand Up @@ -211,7 +210,7 @@ describe('ui-switch node', function () {
const helperAfterComplete = helper.getNode('helper-node-complete')
helperAfterComplete.on('input', (msg) => {
try {
sNode._msg.payload.should.equal(msg.payload)
sNode.getState().payload.should.equal(msg.payload)
msgSent.should.be.false()
resolve()
} catch (err) {
Expand Down
2 changes: 1 addition & 1 deletion test/nodes/widgets/ui_text_input.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ describe('ui-text-input node', function () {
const helperAfterComplete = helper.getNode('helper-node-complete')
helperAfterComplete.on('input', (msg) => {
try {
tNode._msg.payload.should.equal(msg.payload)
tNode.getState().payload.should.equal(msg.payload)
msgSent.should.be.false()
resolve()
} catch (err) {
Expand Down

0 comments on commit 50d902a

Please sign in to comment.