Skip to content

Commit

Permalink
fixed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
delivey committed Aug 29, 2021
1 parent d1cf631 commit 543cbe0
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 4,037 deletions.
53 changes: 9 additions & 44 deletions index.test.js
Original file line number Diff line number Diff line change
@@ -1,46 +1,11 @@
const fs = require('fs');
let file = "./index.html" , dir = "./build";
const axios = require("axios")
const reqless = require("./index");

const url = "http://info.cern.ch/"
const method = "GET"

let rm_file = () => {
fs.unlink(file , (err) =>{
if(err) console.log(err);
})
}

let rm_dir = () => {
if(fs.existsSync(dir)){
fs.rmdir(dir, { recursive: true }, (err) => {
if (err) {
throw err;
}
});
}
}

if (fs.existsSync(file)) rm_file();
else if (fs.existsSync(dir)) rm_dir();


const { execFileSync } = require("child_process");
const reqless = require('./index');

execFileSync('wget', ['http://info.cern.ch/']);

const read_file = fs.readFileSync('./index.html' , {encoding : 'utf-8'});
const response = reqless({
url: "http://info.cern.ch/",
method: "GET"
})

test("reqless test" , () => {
expect(response.body.trim()).toBe(read_file.trim());
})

fs.unlink(file , (err) =>{
if(err) console.log(err);
})

fs.rm(dir, { recursive: true }, (err) => {
if (err) { throw err;}
});
test("HTTP GET" , async () => {
const rql_response = reqless({ url: url, method: method })
const axios_response = await axios({ url: url, method: method })
expect(rql_response.body).toBe(axios_response.data);
})
Loading

0 comments on commit 543cbe0

Please sign in to comment.