Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return new Promise(done => {
const csvFilePath = path.join(samplesFolder, 'sample.csv')
const csvParserPrice = new CsvParserPrice({ apiConfig })
const inputStream = fs.createReadStream(csvFilePath)
const outputStream = streamtest.v2.toText((error, output) => {
const prices = JSON.parse(output).prices
const expected = path.join(
__dirname,
'expected-output',
'csv-parser-price.json'
)
const expectedArray = JSON.parse(fs.readFileSync(expected, 'utf8'))
expect(prices).toBeInstanceOf(Array)
expect(prices).toMatchObject(expectedArray.prices)
expect(prices).toHaveLength(2)
// Because customTypeId is dynamic, match it against uuid regex
expect(isuuid(prices[0].prices[0].custom.type.id)).toBe(true)
beforeAll(() => {
const client = createClient({
middlewares: [
createAuthMiddlewareForClientCredentialsFlow({ ...apiConfig, fetch }),
createHttpMiddleware({
host: CONSTANTS.host.api,
fetch,
}),
],
})
const customTypePayload = {
key: 'custom-type',
name: { nl: 'selwyn' },
resourceTypeIds: ['product-price'],
fieldDefinitions: [
{
type: { name: 'Number' },
name: 'foo',
label: { en: 'said the barman' },
required: true,
},