Skip to content

Commit

Permalink
Added optional descriptions to tests, and properly display them
Browse files Browse the repository at this point in the history
  • Loading branch information
elboletaire committed Nov 23, 2018
1 parent bba516e commit 6ef445f
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 2 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@ To test them, you'll need to add a yaml file (or files, as you can define as man

~~~yaml
- name: operatorName
description: An optional description of your test
input:
# ...
output:
Expand All @@ -281,6 +282,7 @@ Note that it's an array, so you can set as many tests as you want for each opera
Let's see what's every part:

- `operatorName`: The operator name to be tested. Note that it must be `operatorName` not `operator-file-name`!
- `description`: Is shown during the tests, so you can properly know where the logs come from.
- `input`: The payload the queue should receive as input.
- `output`: How should it look after exiting.
- `response`: Used by the HTTP plugin mock. Mocks responses for every specified `actionName`.
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
"dependencies": {
"axios": "^0.18.0",
"axios-mock-adapter": "^1.15.0",
"chalk": "^2.4.1",
"config": "^1.27.0",
"deepmerge": "^2.2.1",
"express": "^4.16.2",
Expand Down
1 change: 0 additions & 1 deletion src/worker/execution-plugins/__mocks__/http.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { HTTPPluginOptionsSchema } from '../../../schemas/PluginOptionsSchema'
import json from '../../../../test/operators-tester.json'
import logger from '../../../services/logger'

export default class HttpPlugin {
Expand Down
1 change: 1 addition & 0 deletions test/members-signup-1.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
- name: membersSignup
description: Case email template is specified in privateMeta
input:
member:
name: John Doe
Expand Down
1 change: 1 addition & 0 deletions test/members-signup-2.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
- name: membersSignup
description: Case email template is NOT specified in privateMeta
input:
member:
name: John Doe
Expand Down
9 changes: 9 additions & 0 deletions test/operators-tester.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import fs from 'fs'
import yaml from 'js-yaml'
import chalk from 'chalk'

import { loadOperators } from '../src/services/OperatorsLoader'
import ActionCreator, { extractMessage } from '../src/worker/ActionCreator'
Expand Down Expand Up @@ -92,6 +93,14 @@ describe('Test operators', () => {
const job = jobs[key]
const { test, operator } = job

process.stdout.write(`\n${chalk.yellow('━')} Running actions for operator ${operator.name}...\n`)

if (test.description) {
process.stdout.write(`${chalk.yellow('┗')} ${test.description}\n`)
}

process.stdout.write('\n')

const results = await executeActions(new Event(operator), test)

expect(results).toEqual(test.output)
Expand Down
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -744,7 +744,7 @@ chalk@^1.1.3:
strip-ansi "^3.0.0"
supports-color "^2.0.0"

chalk@^2.0.0, chalk@^2.0.1:
chalk@^2.0.0, chalk@^2.0.1, chalk@^2.4.1:
version "2.4.1"
resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.4.1.tgz#18c49ab16a037b6eb0152cc83e3471338215b66e"
integrity sha512-ObN6h1v2fTJSmUXoS3nMQ92LbDK9be4TV+6G+omQlGJFdcUX5heKi1LZ1YnRMIgwTLEj3E24bT6tYni50rlCfQ==
Expand Down

0 comments on commit 6ef445f

Please sign in to comment.