Frontend: Add unit tests
This commit is contained in:
parent
4f1ecb6ced
commit
08cca09f22
3 changed files with 58 additions and 0 deletions
|
@ -331,6 +331,8 @@ Mock.onPut("api/v1/faces/f123ghytrfggd", { Hidden: true }).reply(
|
|||
);
|
||||
Mock.onPost("api/v1/subjects/s123ghytrfggd/like").reply(200, { status: "ok" }, mockHeaders);
|
||||
Mock.onDelete("api/v1/subjects/s123ghytrfggd/like").reply(200, { status: "ok" }, mockHeaders);
|
||||
Mock.onGet("api/v1/config/options").reply(200, { success: "ok" }, mockHeaders);
|
||||
Mock.onPost("api/v1/config/options").reply(200, { success: "ok" }, mockHeaders);
|
||||
|
||||
//Mock.onPost().reply(200);
|
||||
//Mock.onDelete().reply(200);
|
||||
|
|
52
frontend/tests/unit/model/config-options_test.js
Normal file
52
frontend/tests/unit/model/config-options_test.js
Normal file
|
@ -0,0 +1,52 @@
|
|||
import "../fixtures";
|
||||
import ConfigOptions from "model/config-options";
|
||||
|
||||
let chai = require("chai/chai");
|
||||
let assert = chai.assert;
|
||||
|
||||
describe("model/config-options", () => {
|
||||
it("should get options defaults", () => {
|
||||
const values = {};
|
||||
const options = new ConfigOptions(values);
|
||||
const result = options.getDefaults();
|
||||
assert.equal(result.Debug, false);
|
||||
assert.equal(result.ReadOnly, false);
|
||||
assert.equal(result.ThumbSize, 0);
|
||||
});
|
||||
|
||||
it("should test changed", () => {
|
||||
const values = {};
|
||||
const options = new ConfigOptions(values);
|
||||
assert.equal(options.changed(), false);
|
||||
});
|
||||
|
||||
it("should load options", (done) => {
|
||||
const values = {};
|
||||
const options = new ConfigOptions(values);
|
||||
options
|
||||
.load()
|
||||
.then((response) => {
|
||||
assert.equal(response.success, "ok");
|
||||
done();
|
||||
})
|
||||
.catch((error) => {
|
||||
done(error);
|
||||
});
|
||||
assert.equal(options.changed(), false);
|
||||
});
|
||||
|
||||
it("should save options", (done) => {
|
||||
const values = { Debug: true };
|
||||
const options = new ConfigOptions(values);
|
||||
options
|
||||
.save()
|
||||
.then((response) => {
|
||||
assert.equal(response.success, "ok");
|
||||
done();
|
||||
})
|
||||
.catch((error) => {
|
||||
done(error);
|
||||
});
|
||||
assert.equal(options.changed(), false);
|
||||
});
|
||||
});
|
|
@ -200,6 +200,10 @@ describe("model/subject", () => {
|
|||
assert.equal(subject.Favorite, true);
|
||||
});
|
||||
|
||||
it("should return batch size", () => {
|
||||
assert.equal(Subject.batchSize(), 60);
|
||||
});
|
||||
|
||||
it("should get collection resource", () => {
|
||||
const result = Subject.getCollectionResource();
|
||||
assert.equal(result, "subjects");
|
||||
|
|
Loading…
Reference in a new issue