Open source omnivore
This commit is contained in:
3
packages/import-handler/test/babel-register.js
Normal file
3
packages/import-handler/test/babel-register.js
Normal file
@ -0,0 +1,3 @@
|
||||
const register = require('@babel/register').default;
|
||||
|
||||
register({ extensions: ['.ts', '.tsx', '.js', '.jsx'] });
|
||||
25
packages/import-handler/test/csv/csv.test.ts
Normal file
25
packages/import-handler/test/csv/csv.test.ts
Normal file
@ -0,0 +1,25 @@
|
||||
import 'mocha'
|
||||
import * as chai from 'chai'
|
||||
import { expect } from 'chai'
|
||||
import 'chai/register-should'
|
||||
import chaiString from 'chai-string'
|
||||
import * as fs from 'fs'
|
||||
import { importCsv } from '../../src/csv'
|
||||
|
||||
chai.use(chaiString)
|
||||
|
||||
describe('Load a simple CSV file', () => {
|
||||
it('should call the handler for each URL', async () => {
|
||||
const urls: URL[] = []
|
||||
const stream = fs.createReadStream('./test/csv/data/simple.csv')
|
||||
const count = await importCsv(stream, (url): Promise<void> => {
|
||||
urls.push(url)
|
||||
return Promise.resolve()
|
||||
})
|
||||
expect(count).to.equal(2)
|
||||
expect(urls).to.eql([
|
||||
new URL('https://omnivore.app'),
|
||||
new URL('https://google.com'),
|
||||
])
|
||||
})
|
||||
})
|
||||
2
packages/import-handler/test/csv/data/simple.csv
Normal file
2
packages/import-handler/test/csv/data/simple.csv
Normal file
@ -0,0 +1,2 @@
|
||||
"https://omnivore.app"
|
||||
"https://google.com"
|
||||
|
Reference in New Issue
Block a user