add lockCategories tests, getUserInfo

This commit is contained in:
Michael C
2022-09-21 02:27:48 -04:00
parent f683ed4f29
commit dd7656d143
2 changed files with 73 additions and 0 deletions

View File

@@ -263,6 +263,15 @@ describe("getUserInfo", () => {
.catch(err => done(err));
});
it("Should throw 400 with invalid array", (done) => {
client.get(endpoint, { params: { userID: "x", values: 123 } })
.then(res => {
assert.strictEqual(res.status, 400);
done(); // pass
})
.catch(err => done(err));
});
it("Should return 200 on userID not found", (done) => {
client.get(endpoint, { params: { userID: "notused-userid" } })
.then(res => {
@@ -307,4 +316,29 @@ describe("getUserInfo", () => {
})
.catch(err => done(err));
});
it("Should be able to get permissions", (done) => {
client.get(endpoint, { params: { userID: "getuserinfo_user_01", value: "permissions" } })
.then(res => {
assert.strictEqual(res.status, 200);
const expected = {
permissions: {
sponsor: true,
selfpromo: true,
exclusive_access: true,
interaction: true,
intro: true,
outro: true,
preview: true,
music_offtopic: true,
filler: true,
poi_highlight: true,
chapter: false,
},
};
assert.ok(partialDeepEquals(res.data, expected));
done(); // pass
})
.catch(err => done(err));
});
});

View File

@@ -560,4 +560,43 @@ describe("lockCategoriesRecords", () => {
})
.catch(err => done(err));
});
it("should be able to add poi type category by type skip", (done) => {
const videoID = "add-record-poi";
client.post(endpoint, {
videoID,
userID: lockVIPUser,
categories: ["poi_highlight"],
actionTypes: ["skip"]
})
.then(res => {
assert.strictEqual(res.status, 200);
checkLockCategories(videoID)
.then(result => {
assert.strictEqual(result.length, 1);
assert.strictEqual(result[0], "poi_highlight");
});
done();
})
.catch(err => done(err));
});
it("Should not add lock of invalid type", (done) => {
const videoID = "add_invalid_type";
client.post(endpoint, {
videoID,
userID: lockVIPUser,
categories: ["future_unused_invalid_type"],
actionTypes: ["skip"]
})
.then(res => {
assert.strictEqual(res.status, 200);
checkLockCategories(videoID)
.then(result => {
assert.strictEqual(result.length, 0);
});
done();
})
.catch(err => done(err));
});
});