Files
amazon-book-search/test/index.js

187 lines
5.2 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
const { expect } = require("chai");
const AmazonBookSearch = require("../index");
describe("📦 Amazon Book Search (Turkish) Integration Test", () => {
let bookSearch;
const isbn = "9944824453";
const geminiApiKey = "AIzaSyAY15XJcK1VIxzMRe48dyDEeNPqeqhQt2I";
const timeoutDuration = 30000;
beforeEach(() => {
bookSearch = new AmazonBookSearch("tr");
});
it('Is the ISBN "9944824453" 🔥', function (done) {
this.timeout(timeoutDuration);
bookSearch
.getBookDetails(isbn)
.then((bookDetails) => {
expect(bookDetails).to.have.property("isbn");
expect(bookDetails.isbn).to.equal("9944824453");
done();
})
.catch(done);
});
it('Is the book title "Dövmeli Adam: İblis Döngüsü 1" 🚀', function (done) {
this.timeout(timeoutDuration);
bookSearch
.getBookDetails(isbn)
.then((bookDetails) => {
expect(bookDetails).to.have.property("title");
expect(bookDetails.title).to.equal("Dövmeli Adam: İblis Döngüsü 1");
done();
})
.catch(done);
});
it("Checks if the book thumb image is not empty 🌄", function (done) {
this.timeout(timeoutDuration);
bookSearch
.getBookDetails(isbn)
.then((bookDetails) => {
expect(bookDetails).to.have.property("thumbImage");
expect(bookDetails.thumbImage).to.be.a("string");
done();
})
.catch(done);
});
it('Is the book\'s publication date "1 Temmuz 2016" ⏰', function (done) {
this.timeout(timeoutDuration);
bookSearch
.getBookDetails(isbn)
.then((bookDetails) => {
expect(bookDetails).to.have.property("date");
expect(bookDetails.date).to.equal("1 Temmuz 2016");
done();
})
.catch(done);
});
it('Is the page count "638" 📋', function (done) {
this.timeout(timeoutDuration);
bookSearch
.getBookDetails(isbn)
.then((bookDetails) => {
expect(bookDetails).to.have.property("page");
expect(bookDetails.page).to.equal(638);
done();
})
.catch(done);
});
it('Is the publisher "Epsilon Yayınları" 📖', function (done) {
this.timeout(timeoutDuration);
bookSearch
.getBookDetails(isbn)
.then((bookDetails) => {
expect(bookDetails).to.have.property("publisher");
expect(bookDetails.publisher).to.equal("Epsilon Yayınları");
done();
})
.catch(done);
});
it("Is the Gemini API test working for the book description 🤖", function (done) {
this.timeout(timeoutDuration);
bookSearch
.getBookDetails(isbn, geminiApiKey)
.then((bookDetails) => {
expect(bookDetails).to.have.property("description");
expect(bookDetails.description).to.be.a("string");
done();
})
.catch(done);
});
});
describe("📦 Amazon Book Search (English) Integration Test", () => {
let bookSearch;
const isbn = "0593724283";
const timeoutDuration = 30000;
before(function (done) {
this.timeout(timeoutDuration + 30000);
setTimeout(done, 30000);
});
beforeEach(() => {
bookSearch = new AmazonBookSearch("en");
});
it('Is the ISBN "0593724283" 🔥', function (done) {
this.timeout(timeoutDuration);
bookSearch
.getBookDetails(isbn)
.then((bookDetails) => {
expect(bookDetails).to.have.property("isbn");
expect(bookDetails.isbn).to.equal("0593724283");
done();
})
.catch(done);
});
it('Is the book title "The Desert Spear: Book Two of The Demon Cycle" 🚀', function (done) {
this.timeout(timeoutDuration);
bookSearch
.getBookDetails(isbn)
.then((bookDetails) => {
expect(bookDetails).to.have.property("title");
expect(bookDetails.title).to.equal(
"The Desert Spear: Book Two of The Demon Cycle"
);
done();
})
.catch(done);
});
it("Checks if the book thumb image is not empty 🌄", function (done) {
this.timeout(timeoutDuration);
bookSearch
.getBookDetails(isbn)
.then((bookDetails) => {
expect(bookDetails).to.have.property("thumbImage");
expect(bookDetails.thumbImage).to.be.a("string");
done();
})
.catch(done);
});
it('Is the book\'s publication date "November 7, 2023" ⏰', function (done) {
this.timeout(timeoutDuration);
bookSearch
.getBookDetails(isbn)
.then((bookDetails) => {
expect(bookDetails).to.have.property("date");
expect(bookDetails.date).to.equal("November 7, 2023");
done();
})
.catch(done);
});
it('Is the page count "864" 📋', function (done) {
this.timeout(timeoutDuration);
bookSearch
.getBookDetails(isbn)
.then((bookDetails) => {
expect(bookDetails).to.have.property("page");
expect(bookDetails.page).to.equal(864);
done();
})
.catch(done);
});
it('Is the publisher "Del Rey" 📖', function (done) {
this.timeout(timeoutDuration);
bookSearch
.getBookDetails(isbn)
.then((bookDetails) => {
expect(bookDetails).to.have.property("publisher");
expect(bookDetails.publisher).to.equal("Del Rey");
done();
})
.catch(done);
});
});