-
Notifications
You must be signed in to change notification settings - Fork 120
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Test systemimage and asteroid_os plugins
- Loading branch information
1 parent
af150fb
commit 456a6e1
Showing
2 changed files
with
97 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" } | ||
]) | ||
)); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" } | ||
]) | ||
)); | ||
}); | ||
}); | ||
}); |