-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
41 additions
and
4,037 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}) |
Oops, something went wrong.