UNPKG

@elastic.io/maester-client

Version:
32 lines (31 loc) 1.98 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const axios_1 = __importDefault(require("axios")); const chai_1 = require("chai"); const StorageClient_1 = require("../src/StorageClient"); const utils_1 = require("../src/utils"); describe('getStreamWithContentType', () => { it('should getStreamWithContentType', async () => { const getJsonAsStream = async () => (0, utils_1.streamFromData)({ a: 4 }); const { mime } = await (0, StorageClient_1.getStreamWithContentType)(getJsonAsStream); (0, chai_1.expect)(mime).to.be.equal('application/json'); }); it('should getStreamWithContentType', async () => { const getAttachAsStream = async () => (await axios_1.default.get('https://if0s.info/files/1.jpg', { responseType: 'stream' })).data; const { mime } = await (0, StorageClient_1.getStreamWithContentType)(getAttachAsStream); (0, chai_1.expect)(mime).to.be.equal('image/jpeg'); }); it('should getStreamWithContentType', async () => { const getAttachAsStream = async () => (await axios_1.default.get('https://raw.githubusercontent.com/elasticio/jsonata-transform-component/master/package-lock.json', { responseType: 'stream' })).data; const { mime } = await (0, StorageClient_1.getStreamWithContentType)(getAttachAsStream); (0, chai_1.expect)(mime).to.be.equal('application/json'); }); it('should getStreamWithContentType', async () => { const getAttachAsStream = async () => (await axios_1.default.get('http://environmentclearance.nic.in/writereaddata/FormB/Agenda/2201201642EWMJ8Bpdf18.pdf', { responseType: 'stream' })).data; const { mime } = await (0, StorageClient_1.getStreamWithContentType)(getAttachAsStream); (0, chai_1.expect)(mime).to.be.equal('application/pdf'); }); });