photoprism/frontend/tests/unit/model/service_test.js

76 lines
2 KiB
JavaScript
Raw Normal View History

import "../fixtures";
import Service from "model/service";
2020-07-01 17:24:24 +02:00
import Photo from "model/photo";
2020-07-02 10:03:00 +02:00
let chai = require("chai/chai");
2020-07-01 17:24:24 +02:00
let assert = chai.assert;
describe("model/service", () => {
it("should get service defaults", () => {
const values = { ID: 5 };
const service = new Service(values);
const result = service.getDefaults();
assert.equal(result.ID, 0);
assert.equal(result.AccShare, true);
assert.equal(result.AccName, "");
});
2020-07-01 17:24:24 +02:00
it("should get service entity name", () => {
const values = { ID: 5, AccName: "Test Name" };
const service = new Service(values);
const result = service.getEntityName();
assert.equal(result, "Test Name");
});
2020-07-01 17:24:24 +02:00
it("should get service id", () => {
const values = { ID: 5, AccName: "Test Name" };
const service = new Service(values);
const result = service.getId();
assert.equal(result, 5);
});
2020-07-01 17:24:24 +02:00
it("should get folders", (done) => {
const values = { ID: 123, AccName: "Test Name" };
const service = new Service(values);
service
.Folders()
.then((response) => {
assert.equal(response.foo, "folders");
done();
})
.catch((error) => {
done(error);
});
});
2020-07-01 17:24:24 +02:00
it("should get share photos", (done) => {
const values = { ID: 123, AccName: "Test Name" };
const service = new Service(values);
const values1 = { ID: 5, Title: "Crazy Cat", UID: 789 };
const photo = new Photo(values1);
const values2 = { ID: 6, Title: "Crazy Cat 2", UID: 783 };
const photo2 = new Photo(values2);
const Photos = [photo, photo2];
service
.Upload(Photos, "destination")
.then((response) => {
assert.equal(response.foo, "upload");
done();
})
.catch((error) => {
done(error);
});
});
2020-07-01 17:24:24 +02:00
it("should get collection resource", () => {
const result = Service.getCollectionResource();
assert.equal(result, "services");
});
2020-07-01 17:24:24 +02:00
it("should get model name", () => {
const result = Service.getModelName();
assert.equal(result, "Account");
});
});