Skip to content

Commit acddbea

Browse files
committed
simplified logic without async lib
1 parent 1320389 commit acddbea

2 files changed

Lines changed: 20 additions & 28 deletions

File tree

test/requests.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
'use strict'
44

5-
var async = require('async')
65
var fixtures = require('./fixtures')
76
var HTTPSnippet = require('../src')
87
var targets = require('../src/targets')
@@ -24,10 +23,10 @@ var requests = [ 'application-form-encoded',
2423
]
2524

2625
// test all the things!
27-
async.each(fixtures.cli, function (cli) {
26+
fixtures.cli.forEach(function (cli) {
2827
describe(targets[cli.target].info.title + ' Request Validation', function () {
29-
async.each(cli.clients, function (client) {
30-
async.each(requests, function (request) {
28+
cli.clients.forEach(function (client) {
29+
requests.forEach(function (request) {
3130
it(client + ' request should match mock for ' + request, function (done) {
3231
var stdout = ''
3332
var fixture = cli.target + '/' + client + '/' + request + HTTPSnippet.extname(cli.target)

test/targets.js

Lines changed: 17 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
'use strict'
44

5-
var async = require('async')
65
var fixtures = require('./fixtures')
76
var fs = require('fs')
87
var glob = require('glob')
@@ -20,8 +19,8 @@ var output = glob.sync('**/*', {cwd: base, nodir: true}).reduce(function (obj, n
2019
return obj
2120
}, {})
2221

23-
var clearInfo = function (key, cb) {
24-
cb(!~['info', 'index'].indexOf(key))
22+
var clearInfo = function (key) {
23+
return !~['info', 'index'].indexOf(key)
2524
}
2625

2726
var itShouldHaveTests = function (test, func, key) {
@@ -74,7 +73,7 @@ describe('Available Targets', function () {
7473
})
7574

7675
// test all the things!
77-
async.each(Object.keys(targets), function (target) {
76+
Object.keys(targets).forEach(function (target) {
7877
describe(targets[target].info.title, function () {
7978
itShouldHaveInfo(targets, target)
8079

@@ -86,35 +85,29 @@ async.each(Object.keys(targets), function (target) {
8685

8786
if (!targets[target].index) {
8887
describe('snippets', function () {
89-
async.filter(Object.keys(fixtures.requests), clearInfo, function (requests) {
90-
async.each(requests, function (request) {
91-
itShouldHaveRequestTestOutputFixture(request, target, '')
88+
Object.keys(fixtures.requests).filter(clearInfo).forEach(function (request) {
89+
itShouldHaveRequestTestOutputFixture(request, target, '')
9290

93-
itShouldGenerateOutput(request, target + '/', target)
94-
})
91+
itShouldGenerateOutput(request, target + '/', target)
9592
})
9693
})
9794
}
9895

99-
async.filter(Object.keys(targets[target]), clearInfo, function (clients) {
100-
async.each(clients, function (client) {
101-
describe(client, function () {
102-
itShouldHaveInfo(targets[target], client)
96+
Object.keys(targets[target]).filter(clearInfo).forEach(function (client) {
97+
describe(client, function () {
98+
itShouldHaveInfo(targets[target], client)
10399

104-
itShouldHaveTests(tests[target], client, client)
100+
itShouldHaveTests(tests[target], client, client)
105101

106-
if (tests[target] && typeof tests[target][client] === 'function') {
107-
tests[target][client](HTTPSnippet, fixtures)
108-
}
102+
if (tests[target] && typeof tests[target][client] === 'function') {
103+
tests[target][client](HTTPSnippet, fixtures)
104+
}
109105

110-
describe('snippets', function () {
111-
async.filter(Object.keys(fixtures.requests), clearInfo, function (requests) {
112-
async.each(requests, function (request) {
113-
itShouldHaveRequestTestOutputFixture(request, target, client + '/')
106+
describe('snippets', function () {
107+
Object.keys(fixtures.requests).filter(clearInfo).forEach(function (request) {
108+
itShouldHaveRequestTestOutputFixture(request, target, client + '/')
114109

115-
itShouldGenerateOutput(request, target + '/' + client + '/', target, client)
116-
})
117-
})
110+
itShouldGenerateOutput(request, target + '/' + client + '/', target, client)
118111
})
119112
})
120113
})

0 commit comments

Comments
 (0)