-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enable email notifications for all servers
- Loading branch information
1 parent
e3771e2
commit 797a272
Showing
6 changed files
with
76 additions
and
19 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
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
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
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
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
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 |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import { stubClient } from "matrix-react-sdk/test/test-utils"; | ||
import SdkConfig, { ConfigOptions } from "matrix-react-sdk/src/SdkConfig"; | ||
import { MatrixClientPeg } from "matrix-react-sdk/src/MatrixClientPeg"; | ||
|
||
import TchapUIFeature from "~tchap-web/src/tchap/util/TchapUIFeature"; | ||
|
||
describe("TchapUIFeature", () => { | ||
const featureName: string = "my_funky_feature"; | ||
const homeserverName: string = "my.home.server"; | ||
|
||
beforeAll(() => { | ||
SdkConfig.reset(); // in case other tests didn't clean up | ||
}); | ||
|
||
beforeEach(() => { | ||
stubClient(); | ||
MatrixClientPeg.getHomeserverName = () => homeserverName; | ||
}); | ||
|
||
afterEach(function () { | ||
SdkConfig.reset(); // we touch the config, so clean up | ||
}); | ||
|
||
const mockFeatureConfig = (homeservers: string[]) => { | ||
// mock SdkConfig.get("tchap_features") | ||
const config: ConfigOptions = { tchap_features: {} }; | ||
config.tchap_features[featureName] = homeservers; | ||
SdkConfig.put(config); | ||
}; | ||
|
||
it("returns true when the user's homeserver is listed in config", () => { | ||
mockFeatureConfig([homeserverName, "some.other.server"]); | ||
expect(TchapUIFeature.isFeatureActiveForHomeserver(featureName)).toEqual(true); | ||
}); | ||
|
||
it("returns false when the user's homeserver is not listed in config", () => { | ||
mockFeatureConfig(["some.other.server"]); | ||
expect(TchapUIFeature.isFeatureActiveForHomeserver(featureName)).toEqual(false); | ||
}); | ||
|
||
it("returns true when '*' is alone in config", () => { | ||
mockFeatureConfig(["*"]); | ||
expect(TchapUIFeature.isFeatureActiveForHomeserver(featureName)).toEqual(true); | ||
}); | ||
|
||
it("returns true when '*' is anywhere in config", () => { | ||
mockFeatureConfig(["some.other.server", "*"]); | ||
expect(TchapUIFeature.isFeatureActiveForHomeserver(featureName)).toEqual(true); | ||
}); | ||
|
||
it("returns false when no tchap_features in config", () => { | ||
const config: ConfigOptions = {}; | ||
SdkConfig.put(config); | ||
expect(TchapUIFeature.isFeatureActiveForHomeserver(featureName)).toEqual(false); | ||
}); | ||
}); |