Skip to content

Commit

Permalink
test: update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
milo526 committed Jan 8, 2023
1 parent 2554c18 commit 64a63a1
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions test/tuyawebapi.spec.ts
Expand Up @@ -7,7 +7,7 @@ import { before, describe, it } from "mocha";
// Global variables used in the tests

describe("TuyaWebApi", () => {
let api;
let api: TuyaWebApi;

before(() => {
api = new TuyaWebApi(
Expand All @@ -22,10 +22,9 @@ describe("TuyaWebApi", () => {
it("should get an access token from the web api", (done) => {
api
.getOrRefreshToken()
.then((session) => {
api.session = session || null;
.then(() => {
assert.notStrictEqual(
session.accessToken,
api["session"]?.accessToken,
null,
"No valid access token."
);
Expand All @@ -38,7 +37,7 @@ describe("TuyaWebApi", () => {

it("should have the area base url set to EU server", (done) => {
assert.strictEqual(
api.session.areaBaseUrl,
api["session"]?.areaBaseUrl,
"https://px1.tuyaeu.com",
"Area Base URL is not set."
);
Expand All @@ -51,7 +50,7 @@ describe("TuyaWebApi", () => {
api
.discoverDevices()
.then((devices) => {
assert.notStrictEqual(devices.length, 0, "No devices found");
assert.notStrictEqual((devices || []).length, 0, "No devices found");
done();
})
.catch((error) => {
Expand Down

0 comments on commit 64a63a1

Please sign in to comment.