summaryrefslogtreecommitdiff
path: root/test/helpers.ts
diff options
context:
space:
mode:
Diffstat (limited to 'test/helpers.ts')
-rw-r--r--test/helpers.ts48
1 files changed, 48 insertions, 0 deletions
diff --git a/test/helpers.ts b/test/helpers.ts
index 95d30b0e..41d8fbdf 100644
--- a/test/helpers.ts
+++ b/test/helpers.ts
@@ -8,6 +8,7 @@ import {
parseTag,
compareNames,
getLatestVersionTag,
+ shouldFeatureRun,
} from '../source/github-helpers';
test('getConversationNumber', t => {
@@ -135,3 +136,50 @@ test('getLatestVersionTag', t => {
'v1.0-1',
]), 'lol v0.0.0', 'Non-version tags should short-circuit the sorting and return the first tag');
});
+
+test('shouldFeatureRun', t => {
+ const yes = (): boolean => true;
+ const no = (): boolean => false;
+ const yesYes = [yes, yes];
+ const yesNo = [yes, no];
+ const noNo = [no, no];
+
+ t.true(shouldFeatureRun({}), 'A lack of conditions should mean "run everywhere"');
+
+ t.false(shouldFeatureRun({
+ asLongAs: yesNo,
+ }), 'Every `asLongAs` should be true to run');
+
+ t.false(shouldFeatureRun({
+ asLongAs: yesNo,
+ include: [yes],
+ }), 'Every `asLongAs` should be true to run, regardless of `include`');
+
+ t.false(shouldFeatureRun({
+ include: noNo,
+ }), 'At least one `include` should be true to run');
+
+ t.true(shouldFeatureRun({
+ include: yesNo,
+ }), 'If one `include` is true, then it should run');
+
+ t.false(shouldFeatureRun({
+ exclude: yesNo,
+ }), 'If any `exclude` is true, then it should not run');
+
+ t.false(shouldFeatureRun({
+ include: [yes],
+ exclude: yesNo,
+ }), 'If any `exclude` is true, then it should not run, regardless of `include`');
+
+ t.false(shouldFeatureRun({
+ asLongAs: [yes],
+ exclude: yesNo,
+ }), 'If any `exclude` is true, then it should not run, regardless of `asLongAs`');
+
+ t.false(shouldFeatureRun({
+ asLongAs: [yes],
+ include: yesYes,
+ exclude: yesNo,
+ }), 'If any `exclude` is true, then it should not run, regardless of `asLongAs` and `include`');
+});