Skip to content

Commit

Permalink
Test systemimage and asteroid_os plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
NeoTheThird committed Mar 4, 2021
1 parent af150fb commit 456a6e1
Show file tree
Hide file tree
Showing 2 changed files with 97 additions and 6 deletions.
39 changes: 36 additions & 3 deletions src/core/plugins/asteroid_os/plugin.spec.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,37 @@
const systemimage = require("./plugin.js");
const api = require("./api.js");
jest.mock("./api.js");
api.getImages.mockResolvedValue("a");
api.getChannels.mockResolvedValue(["1.0", "nightlies"]);
const asteroid_os = new (require("./plugin.js"))({
os: { name: "Asteroid OS" },
config: { codename: "lenok" },
settings: { channel: "1.0" }
});

it("should be a singleton", () =>
expect(systemimage).toEqual(require("./plugin.js")));
describe("asteroid_os plugin", () => {
describe("actions", () => {
describe("download", () => {
it("should create download steps", () =>
asteroid_os.action__download().then(r =>
expect(r).toEqual([
{
actions: [
{ "core:download": { files: "a", group: "AsteroidOS" } }
]
}
])
));
});
});
describe("remote_values", () => {
describe("channels", () => {
it("should resolve channels", () =>
asteroid_os.remote_values__channels().then(r =>
expect(r).toEqual([
{ label: "1.0", value: "1.0" },
{ label: "nightlies", value: "nightlies" }
])
));
});
});
});
64 changes: 61 additions & 3 deletions src/core/plugins/systemimage/plugin.spec.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,62 @@
const systemimage = require("./plugin.js");
const api = require("./api.js");
jest.mock("./api.js");
api.getImages.mockResolvedValue({
files: [{ url: "a/s/d/f" }],
commands: "here be dragons"
});
api.getChannels.mockResolvedValue([
"ubports-touch/16.04/devel",
"ubports-touch/16.04/stable"
]);
const systemimage = new (require("./plugin.js"))({
os: { name: "Ubuntu Touch" },
config: { codename: "bacon" },
settings: { channel: "ubports-touch/16.04/stable" }
});

it("should be a singleton", () =>
expect(systemimage).toEqual(require("./plugin.js")));
describe("systemimage plugin", () => {
describe("actions", () => {
describe("download", () => {
it("should create download steps", () =>
systemimage.action__install().then(r => {
expect(r).toHaveLength(1);
expect(r[0].actions).toHaveLength(5);
expect(r[0].actions).toContainEqual({
"core:download": {
files: [{ url: "a/s/d/f" }],
group: "Ubuntu Touch"
}
});
expect(r[0].actions).toContainEqual({
"core:write": {
content: "here be dragons",
file: "ubuntu_command",
group: "Ubuntu Touch"
}
});
expect(r[0].actions).toContainEqual({ "adb:wait": null });
expect(r[0].actions).toContainEqual({
"adb:preparesystemimage": null
});
expect(r[0].actions).toContainEqual({
"adb:push": {
dest: "/cache/recovery/",
files: ["f", "ubuntu_command"],
group: "Ubuntu Touch"
}
});
}));
});
});
describe("remote_values", () => {
describe("channels", () => {
it("should resolve channels", () =>
systemimage.remote_values__channels().then(r =>
expect(r).toEqual([
{ label: "16.04/stable", value: "ubports-touch/16.04/stable" },
{ label: "16.04/devel", value: "ubports-touch/16.04/devel" }
])
));
});
});
});

0 comments on commit 456a6e1

Please sign in to comment.