Files
David Taylor b3015f51ca DEV: Sort imports
Automatically generated by `eslint --fix` to satisfy the updated configuration
2023-10-10 21:46:54 +01:00

76 lines
1.8 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { setupTest } from "ember-qunit";
import { module, test } from "qunit";
import Sharing from "discourse/lib/sharing";
module("Unit | Utility | sharing", function (hooks) {
setupTest(hooks);
hooks.beforeEach(function () {
Sharing._reset();
});
hooks.afterEach(function () {
Sharing._reset();
});
test("addSource", function (assert) {
const sharingSettings = "facebook|twitter";
assert.blank(Sharing.activeSources(sharingSettings));
Sharing.addSource({
id: "facebook",
});
assert.strictEqual(Sharing.activeSources(sharingSettings).length, 1);
});
test("addSharingId", function (assert) {
const sharingSettings = "";
assert.blank(Sharing.activeSources(sharingSettings));
Sharing.addSource({
id: "new-source",
});
assert.blank(
Sharing.activeSources(sharingSettings),
"it doesn’t activate a source not in settings"
);
Sharing.addSharingId("new-source");
assert.strictEqual(
Sharing.activeSources(sharingSettings).length,
1,
"it adds sharing id to existing sharing settings"
);
const privateContext = true;
Sharing.addSource({
id: "another-source",
});
Sharing.addSharingId("another-source");
assert.strictEqual(
Sharing.activeSources(sharingSettings, privateContext).length,
0,
"it does not add a regular source to sources in a private context"
);
Sharing.addSource({
id: "a-private-friendly-source",
showInPrivateContext: true,
});
Sharing.addSharingId("a-private-friendly-source");
assert.strictEqual(
Sharing.activeSources(sharingSettings, privateContext).length,
1,
"it does not add a regular source to sources in a private context"
);
});
});