This repository has been archived on 2023-03-18. You can view files and clone it, but cannot push or open issues or pull requests.
osr-discourse-src/app/assets/javascripts/discourse/tests/integration/components/image-uploader-test.js
Robin Ward 71d37953d5 REFACTOR: Import QUnit and related helpers rather than globals
We used many global functions to handle tests when they should be
imported like other libraries in our application. This also gets us
closer to the way Ember CLI prefers our tests to be laid out.
2020-10-07 11:50:49 -04:00

91 lines
1.9 KiB
JavaScript

import { moduleForComponent } from "ember-qunit";
import componentTest from "discourse/tests/helpers/component-test";
moduleForComponent("image-uploader", { integration: true });
componentTest("with image", {
template:
"{{image-uploader imageUrl='/images/avatar.png' placeholderUrl='/not/used.png'}}",
async 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,
1,
"it displays the trash icon"
);
assert.equal(
find(".placeholder-overlay").length,
0,
"it does not display the placeholder image"
);
await click(".image-uploader-lightbox-btn");
assert.equal(
$(".mfp-container").length,
1,
"it displays the image lightbox"
);
},
});
componentTest("without image", {
template: "{{image-uploader}}",
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"
);
},
});
componentTest("with placeholder", {
template: "{{image-uploader placeholderUrl='/images/avatar.png'}}",
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"
);
},
});