"...backbone-message-format.git" did not exist on "a0ae5a208cccc1a3b4127da25f5c948bb2f8ec56"
Unverified Commit 43b2b99f authored by Dan Jones's avatar Dan Jones
Browse files

test: initial setup of cucumber

parent ec074c62
......@@ -50,6 +50,7 @@ This will be provided by the backbone operator or requested via the API.
```json
{
"api": "[backbone api root url]",
"client_id": "unique-client-id",
"client_name": "UniqueClientName",
"subscription": "dot.delimited.topic.subscription.#",
......
module.exports = {
default: `--format-options '{"snippetInterface": "synchronous"}'`
}
\ No newline at end of file
Feature: Does the adapter work?
The adapter behaves as expected
Scenario: Axios is mocked
Given a mock adapter
Then axios mock works
\ No newline at end of file
Feature: Is it Friday yet?
Everybody wants to know when it's Friday
Scenario: Sunday isn't Friday
Given today is Sunday
When I ask whether it's Friday yet
Then I should be told "Nope"
\ No newline at end of file
const assert = require('assert');
const { Given, When, Then } = require('@cucumber/cucumber');
var axios = require("axios");
var MockAdapter = require("axios-mock-adapter");
// This sets the mock adapter on the default instance
var mockAxios = new MockAdapter(axios);
const mockConfig = require('../../test/mock/config.json');
const mockSchema = require('../../test/mock/swagger.json');
const Adapter = require('../../src/adapter');
const GenericProtocol = require('../../src/protocol');
function isItFriday(today) {
return 'Nope';
}
Given('today is Sunday', function () {
this.today = 'Sunday';
});
When('I ask whether it\'s Friday yet', function () {
this.actualAnswer = isItFriday(this.today);
});
Then('I should be told {string}', function (expectedAnswer) {
assert.strictEqual(this.actualAnswer, expectedAnswer);
});
Given('a mock adapter', function() {
let mockProtocol = new GenericProtocol(mockSchema);
let mockAdapter = new Adapter(mockProtocol, mockConfig);
this.adapter = mockAdapter;
});
Then('axios mock works', function() {
// Mock any GET request to /users
// arguments for reply are (status, data, headers)
mock.onGet("/users").reply(200, {
users: [{ id: 1, name: "John Smith" }],
});
axios.get("/users").then(function (response) {
console.log(response.data);
});
});
......@@ -23,7 +23,7 @@
"lint": "yarn lint:js && yarn lint:prettier",
"lintfix": "prettier --write --list-different . && yarn lint:js --fix",
"prepare": "husky install",
"test": "jest",
"test": "cucumber-js",
"build": "cross-env NODE_ENV=production rollup -c"
},
"lint-staged": {
......@@ -40,10 +40,11 @@
"@babel/eslint-parser": "^7.0.0",
"@commitlint/cli": "^15.0.0",
"@commitlint/config-conventional": "^15.0.0",
"@cucumber/cucumber": "^8.10.0",
"@rollup/plugin-babel": "^6.0.3",
"axios-mock-adapter": "^1.21.2",
"babel-jest": "^27.4.4",
"cross-env": "^7.0.3",
"cucumber": "^6.0.7",
"eslint": "^8.4.1",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-prettier": "^4.2.1",
......
{
"api": "https://example.backbone.com/api",
"client_id": "unique-client-id",
"client_name": "UniqueClientName",
"subscription": "dot.delimited.topic.subscription.#",
"secret": "TheGeeseFlySouthInWinter"
}
\ No newline at end of file
This diff is collapsed.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment