2018-11-12 15:55:56 +08:00
|
|
|
import componentTest from "helpers/component-test";
|
|
|
|
moduleForComponent("image-uploader", { integration: true });
|
|
|
|
|
2018-11-12 16:19:17 +08:00
|
|
|
componentTest("with image", {
|
2019-05-01 21:44:45 +08:00
|
|
|
template:
|
2020-07-18 02:57:25 +08:00
|
|
|
"{{image-uploader imageUrl='/images/avatar.png' placeholderUrl='/not/used.png'}}",
|
2018-11-12 16:19:17 +08:00
|
|
|
|
2019-02-20 13:55:55 +08:00
|
|
|
async test(assert) {
|
2018-11-12 16:19:17 +08:00
|
|
|
assert.equal(
|
2019-02-25 23:04:55 +08:00
|
|
|
find(".d-icon-far-image").length,
|
2018-11-12 16:19:17 +08:00
|
|
|
1,
|
|
|
|
"it displays the upload icon"
|
|
|
|
);
|
|
|
|
|
|
|
|
assert.equal(
|
2019-02-25 23:04:55 +08:00
|
|
|
find(".d-icon-far-trash-alt").length,
|
2018-11-12 16:19:17 +08:00
|
|
|
1,
|
|
|
|
"it displays the trash icon"
|
|
|
|
);
|
2019-02-20 13:55:55 +08:00
|
|
|
|
2019-05-01 21:44:45 +08:00
|
|
|
assert.equal(
|
|
|
|
find(".placeholder-overlay").length,
|
|
|
|
0,
|
|
|
|
"it does not display the placeholder image"
|
|
|
|
);
|
|
|
|
|
2019-02-21 10:13:37 +08:00
|
|
|
await click(".image-uploader-lightbox-btn");
|
2019-02-20 13:55:55 +08:00
|
|
|
|
|
|
|
assert.equal(
|
2019-02-21 10:13:37 +08:00
|
|
|
$(".mfp-container").length,
|
2019-02-20 13:55:55 +08:00
|
|
|
1,
|
2019-02-21 10:13:37 +08:00
|
|
|
"it displays the image lightbox"
|
2019-02-20 13:55:55 +08:00
|
|
|
);
|
2018-11-12 16:19:17 +08:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2018-11-12 15:55:56 +08:00
|
|
|
componentTest("without image", {
|
|
|
|
template: "{{image-uploader}}",
|
|
|
|
|
|
|
|
test(assert) {
|
2018-11-12 16:19:17 +08:00
|
|
|
assert.equal(
|
2019-02-25 23:04:55 +08:00
|
|
|
find(".d-icon-far-image").length,
|
2018-11-12 16:19:17 +08:00
|
|
|
1,
|
|
|
|
"it displays the upload icon"
|
|
|
|
);
|
|
|
|
|
2018-11-12 15:55:56 +08:00
|
|
|
assert.equal(
|
2019-02-25 23:04:55 +08:00
|
|
|
find(".d-icon-far-trash-alt").length,
|
2018-11-12 15:55:56 +08:00
|
|
|
0,
|
|
|
|
"it does not display trash icon"
|
|
|
|
);
|
2019-02-20 13:55:55 +08:00
|
|
|
|
|
|
|
assert.equal(
|
2019-02-25 23:04:55 +08:00
|
|
|
find(".image-uploader-lightbox-btn").length,
|
2019-02-20 13:55:55 +08:00
|
|
|
0,
|
2019-02-21 10:13:37 +08:00
|
|
|
"it does not display the button to open image lightbox"
|
2019-02-20 13:55:55 +08:00
|
|
|
);
|
2018-11-12 15:55:56 +08:00
|
|
|
}
|
|
|
|
});
|
2019-05-01 21:44:45 +08:00
|
|
|
|
|
|
|
componentTest("with placeholder", {
|
2020-07-17 04:23:54 +08:00
|
|
|
template: "{{image-uploader placeholderUrl='/images/avatar.png'}}",
|
2019-05-01 21:44:45 +08:00
|
|
|
|
|
|
|
test(assert) {
|
|
|
|
assert.equal(
|
|
|
|
find(".d-icon-far-image").length,
|
|
|
|
1,
|
|
|
|
"it displays the upload icon"
|
|
|
|
);
|
|
|
|
|
|
|
|
assert.equal(
|
|
|
|
find(".d-icon-far-trash-alt").length,
|
|
|
|
0,
|
|
|
|
"it does not display trash icon"
|
|
|
|
);
|
|
|
|
|
|
|
|
assert.equal(
|
|
|
|
find(".image-uploader-lightbox-btn").length,
|
|
|
|
0,
|
|
|
|
"it does not display the button to open image lightbox"
|
|
|
|
);
|
|
|
|
|
|
|
|
assert.equal(
|
|
|
|
find(".placeholder-overlay").length,
|
|
|
|
1,
|
|
|
|
"it displays the placeholder image"
|
|
|
|
);
|
|
|
|
}
|
|
|
|
});
|