Skip to content

Commit

Permalink
test: use each to traverse samples
Browse files Browse the repository at this point in the history
  • Loading branch information
wdavidw committed Mar 4, 2023
1 parent 74d6608 commit 932772c
Show file tree
Hide file tree
Showing 11 changed files with 34 additions and 38 deletions.
2 changes: 1 addition & 1 deletion packages/csv-generate/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"@types/node": "^18.11.9",
"@types/should": "^13.0.0",
"coffeescript": "~2.7.0",
"each": "^1.2.2",
"each": "^2.2.1",
"eslint": "^8.27.0",
"mocha": "~10.1.0",
"rollup": "^3.2.5",
Expand Down
8 changes: 4 additions & 4 deletions packages/csv-generate/test/samples.coffee
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@

import each from 'each'
import fs from 'fs'
import path from 'path'
import { exec } from 'child_process'

import { fileURLToPath } from 'url'
__dirname = path.dirname fileURLToPath import.meta.url
dir = path.resolve __dirname, '../samples'
samples = fs.readdirSync dir
samples = fs.readdirSync(dir).filter (sample) -> /\.js$/.test sample

describe 'Samples', ->

samples.map (sample) ->
return unless /\.js$/.test sample

each samples, (sample) ->
it "Sample #{sample}", (callback) ->
exec "node #{path.resolve dir, sample}", (err) ->
callback err
2 changes: 1 addition & 1 deletion packages/csv-parse/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
"coffeescript": "^2.7.0",
"csv-generate": "^4.2.2",
"csv-spectrum": "^1.0.0",
"each": "^1.2.2",
"each": "^2.2.1",
"eslint": "^8.27.0",
"mocha": "^10.1.0",
"pad": "^3.2.0",
Expand Down
14 changes: 6 additions & 8 deletions packages/csv-parse/test/samples.coffee
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@

import each from 'each'
import fs from 'fs'
import path from 'path'
import { exec } from 'child_process'

import { fileURLToPath } from 'url'
__dirname = path.dirname fileURLToPath import.meta.url
dir = path.resolve __dirname, '../samples'
samples = fs.readdirSync dir
[_, major] = process.version.match(/(\d+)\.\d+\.\d+/)
samples = fs.readdirSync(dir)
.filter (sample) -> ! (major < 16 && sample is 'recipe.promises.js')
.filter (sample) -> /\.js$/.test sample

describe 'Samples', ->

samples
.filter (sample) ->
return false if major < 16 && sample is 'recipe.promises.js'
true
.map (sample) ->
return unless /\.js$/.test sample

each samples, (sample) ->
it "Sample #{sample}", (callback) ->
exec "node #{path.resolve dir, sample}", (err) ->
callback err
15 changes: 6 additions & 9 deletions packages/csv-parse/test/spectrum.coffee
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@

import { default as spectrum } from 'csv-spectrum'
import { default as each } from 'each'
import { parse } from '../lib/index.js'
import { parse } from '../lib/sync.js'

describe 'spectrum', ->

it 'pass all tests', (next) ->
spectrum (err, tests) ->
each tests
.call (test, next) ->
return next() if test.name is 'simple' # See https://github.com/maxogden/csv-spectrum/commit/ec45e96a79661d7bd87f6becbb845b30f11accde
parse test.csv.toString(), columns: true, (err, records) ->
return next err if err
records.should.eql JSON.parse test.json.toString()
next()
.next next
each tests, (test) ->
return if test.name is 'simple' # See https://github.com/maxogden/csv-spectrum/commit/ec45e96a79661d7bd87f6becbb845b30f11accde
records = parse test.csv.toString(), columns: true
records.should.eql JSON.parse test.json.toString()
.then (-> next()), next
2 changes: 1 addition & 1 deletion packages/csv-stringify/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"@types/should": "^13.0.0",
"coffeescript": "~2.7.0",
"csv-generate": "^4.2.2",
"each": "^1.2.2",
"each": "^2.2.1",
"eslint": "^8.27.0",
"express": "^4.18.2",
"mocha": "~10.1.0",
Expand Down
8 changes: 4 additions & 4 deletions packages/csv-stringify/test/samples.coffee
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@

import each from 'each'
import fs from 'fs'
import path from 'path'
import { exec } from 'child_process'

import { fileURLToPath } from 'url'
__dirname = path.dirname fileURLToPath import.meta.url
dir = path.resolve __dirname, '../samples'
samples = fs.readdirSync dir
samples = fs.readdirSync(dir).filter (sample) -> /\.js$/.test sample

describe 'Samples', ->

samples.map (sample) ->
return unless /\.js$/.test sample

each samples, (sample) ->
it "Sample #{sample}", (callback) ->
exec "node #{path.resolve dir, sample}", (err) ->
callback err
1 change: 1 addition & 0 deletions packages/csv/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"@types/node": "^18.11.9",
"@types/should": "^13.0.0",
"coffeescript": "~2.7.0",
"each": "^2.2.1",
"eslint": "^8.27.0",
"mocha": "~10.1.0",
"rollup": "^3.2.5",
Expand Down
10 changes: 5 additions & 5 deletions packages/csv/test/samples.coffee
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@

import each from 'each'
import fs from 'fs'
import path from 'path'
import {exec} from 'child_process'
import { exec } from 'child_process'

import { fileURLToPath } from 'url'
__dirname = path.dirname fileURLToPath import.meta.url
dir = path.resolve __dirname, '../samples'
samples = fs.readdirSync dir
samples = fs.readdirSync(dir).filter (sample) -> /\.js$/.test sample

describe 'Samples', ->

samples.map (sample) ->
return unless /\.js$/.test sample

each samples, (sample) ->
it "Sample #{sample}", (callback) ->
exec "node #{path.resolve dir, sample}", (err) ->
callback err
2 changes: 1 addition & 1 deletion packages/stream-transform/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"@types/node": "^18.11.9",
"coffeescript": "~2.7.0",
"csv-generate": "^4.2.2",
"each": "^1.2.2",
"each": "^2.2.1",
"eslint": "^8.27.0",
"mocha": "~10.1.0",
"pad": "~3.2.0",
Expand Down
8 changes: 4 additions & 4 deletions packages/stream-transform/test/samples.coffee
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@

import each from 'each'
import fs from 'fs'
import path from 'path'
import { exec } from 'child_process'

import { fileURLToPath } from 'url'
__dirname = path.dirname fileURLToPath import.meta.url
dir = path.resolve __dirname, '../samples'
samples = fs.readdirSync dir
samples = fs.readdirSync(dir).filter (sample) -> /\.js$/.test sample

describe 'Samples', ->

samples.map (sample) ->
return unless /\.js$/.test sample

each samples, (sample) ->
it "Sample #{sample}", (callback) ->
exec "node #{path.resolve dir, sample}", (err) ->
callback err

0 comments on commit 932772c

Please sign in to comment.