This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const test = require('tape') | |
test('isValidInterface() should take an interface model and an input object and check for type matching, no arrays', function ({ deepEqual, end }) { | |
const model = { | |
a: 'string', | |
b: 'object', | |
c: 'boolean', | |
d: 'number' | |
} | |
const data = { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const test = require('tape') | |
test('isValidInterface() should take an interface model and an input object and check for type matching', function ({deepEqual, end}) { | |
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defineStep('every element on {string} property has {string}', async function (property, option, table) { | |
const propFromResponse = get(this.response, property, {}) | |
if (option === 'interface') { | |
const model = table.rowsHash() // to format a table of 2 columns | |
const actual = isValidInterface(model, propFromResponse) | |
const expected = true | |
deepStrictEqual(actual, expected) | |
} | |
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { deepStrictEqual } = require('assert') | |
defineStep('I receive a {int} status code response', async function (status) { | |
const actual = this.response.statusCode | |
const expected = status | |
deepStrictEqual(actual, expected) | |
/* | |
It will throw if the response status code is different than 200 for the scenario we are testing. | |
But you could reuse this step for any expected status |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const got = require('got') | |
defineStep('I make a {string} request to {string}', async function (method, endpoint) { | |
const headers = this.headers // get headers previously saved to the world store | |
const uri = new URL(endpoint, 'localhost:3000') // Compose URL with WHATWG URL API | |
const options = { headers, method } // Create request options | |
// save the response in the world namespace and parse the body | |
this.response = await got(uri, options) | |
this.response.body = JSON.parse(get(this.response, 'body', '{}')) | |
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defineStep('request headers', async function (table) { | |
this.headers = table.rowsHash() // we will format the headers and store it in world namespace for further use | |
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defineStep('request headers', async function (table) {}) | |
defineStep('I make a {string} request to {string}', async function (method, endpoint) {}) | |
defineStep('I receive a {int} status code response', async function (status) {}) | |
defineStep('every element on {string} property has {string}', async function (property, option, table) {}) | |
defineStep('{string} property has more than {int} element', async function (property, number) {}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Feature: Stores | |
As a consumer of the API, | |
I want to be able to perform CRUD operations on stores endpoints | |
Scenario: Successfully get a list of stores near me | |
Given request headers | |
| content-type | application/json | | |
When I make a "GET" request to "stores" | |
Then I receive a 200 status code response | |
And every element on "body" property has "interface" | |
| metadata | object | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const test = require('tape') | |
test('timing test', function (t) { | |
t.plan(2) | |
t.equal(typeof Date.now, 'function') | |
var start = Date.now() | |
setTimeout(function () { | |
t.equal(Date.now() - start, 100) | |
}, 100) | |
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { setWorldConstructor } = require('cucumber') | |
function CustomWorld () {} | |
setWorldConstructor(CustomWorld) |