Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Communications Backbone System
backbone-adapter-javascript
Commits
bb722d6b
Unverified
Commit
bb722d6b
authored
2 years ago
by
Dan Jones
Browse files
Options
Download
Email Patches
Plain Diff
test: add tests for adapter broadcast method
parent
b3e0ef86
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
46 additions
and
2 deletions
+46
-2
features/adapter_broadcast.feature
features/adapter_broadcast.feature
+18
-0
test/cucumber/adapter/before.steps.js
test/cucumber/adapter/before.steps.js
+2
-2
test/cucumber/adapter/broadcast.steps.js
test/cucumber/adapter/broadcast.steps.js
+26
-0
No files found.
features/adapter_broadcast.feature
0 → 100644
View file @
bb722d6b
Feature
:
Can the adapter broadcast messages?
The adapter publish method works as expected
Scenario
:
A
message can be published successfully
Given
valid config
When
the adapter instance is created
When
the auth method is called
When
a mock notify API response is configured to return success
When
the broadcast method is called
Then
a successful response is returned with status 200
Scenario
:
A
failed publish returns a 403
Given
valid config
When
the adapter instance is created
When
the auth method is called
When
a mock notify API response is configured to return an error
When
the broadcast method is called
Then
an error response is returned with status 403
\ No newline at end of file
This diff is collapsed.
Click to expand it.
test/cucumber/adapter/before.steps.js
View file @
bb722d6b
...
...
@@ -60,8 +60,8 @@ Before(function() {
this
.
tracker
=
tracker
;
this
.
recorder
=
recorder
;
let
services
=
{
recorder
:
this
.
recorder
,
tracker
:
this
.
tracker
recorder
,
tracker
};
this
.
protocol
=
new
TrackedGenericProtocol
(
this
.
schema
,
services
);
this
.
protocol
.
resetTracker
();
...
...
This diff is collapsed.
Click to expand it.
test/cucumber/adapter/broadcast.steps.js
0 → 100644
View file @
bb722d6b
const
assert
=
require
(
'
assert
'
);
const
{
When
,
Then
}
=
require
(
'
@cucumber/cucumber
'
);
const
{
fixtures
}
=
require
(
'
../../fixtures/server
'
);
const
mockValidConfig
=
fixtures
.
get
(
'
config-valid
'
);
When
(
'
a mock notify API response is configured to return success
'
,
function
()
{
const
response
=
{};
this
.
mockAxios
.
onPost
(
`
${
mockValidConfig
.
api
}
/notify`
,
).
reply
(
200
,
response
);
});
When
(
'
a mock notify API response is configured to return an error
'
,
function
()
{
this
.
mockAxios
.
onPost
(
`
${
mockValidConfig
.
api
}
/notify`
,
).
reply
(
403
,
{
message
:
'
Token expired
'
})
});
When
(
'
the broadcast method is called
'
,
function
()
{
const
message
=
fixtures
.
get
(
'
message-vehicle-status
'
);
this
.
message
=
message
;
const
body
=
JSON
.
stringify
(
message
);
this
.
call
=
this
.
adapter
.
broadcast
(
body
);
});
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment