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