Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Alphka committed Jul 31, 2023
1 parent b8ec22e commit 6f76779
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
- name: Install dependencies
run: npm ci --fund=false
- name: Type checking
run: npx tsc -p jsconfig.json
run: npm run lint
- name: Test project
run: npm test
env:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.vscode
node_modules
output
tests/*
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
{
"author": "Alphka",
"name": "insta-downloader",
"version": "2.0.0",
"version": "2.0.1",
"description": "An application to download content of Instagram with the correct modified date",
"main": "src/index.js",
"scripts": {
"start": "node --no-warnings .",
"test": "node --no-warnings --test tests/",
"test:watch": "node --no-warnings --test --watch tests/"
"test:watch": "node --no-warnings --test --watch tests/",
"lint": "tsc -p jsconfig.json"
},
"keywords": [
"instagram",
Expand Down
6 changes: 3 additions & 3 deletions src/Downloader.js
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ export default class Downloader {
Object.assign(config, { responseType: "arraybuffer" })

/** @type {import("axios").AxiosResponse<Buffer>} */
const { data } = await axios.get(url, config)
const { data } = await this.Request(url, "GET", config)
const { format } = await sharp(data).metadata()
const path = join(folder, `${name}.${format === "jpeg" ? "jpg" : format}`)

Expand All @@ -428,7 +428,7 @@ export default class Downloader {
Object.assign(config, { responseType: "stream" })

/** @type {import("axios").AxiosResponse<import("stream").PassThrough>} */
const { data } = await axios.get(url, config)
const { data } = await this.Request(url, "GET", config)
const path = join(folder, filename)
const file = createWriteStream(path)

Expand Down Expand Up @@ -494,7 +494,7 @@ export default class Downloader {
if(config.app_id && config.queryHash) return

const response = await this.Request(new URL(usernames[0], BASE_URL), "GET", { responseType: "text" })
const appId = response.data.match(/X-IG-App-ID":"(\d+)"/)?.[1]
const appId = response.data.match(/"X-IG-App-ID":"(\d+)"/)?.[1]
const queryHash = response.data.match(/"query_hash":"([a-z0-9]+)"/)?.[1]

config.queryHash = queryHash
Expand Down
1 change: 1 addition & 0 deletions tests/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ test("Instagram API", async t => {

await t.test("should get app id", async () => {
await downloader.CheckServerConfig()
downloader.UpdateHeaders()

const { app_id, queryHash } = downloader.config

Expand Down

0 comments on commit 6f76779

Please sign in to comment.