timeago.TestOptionIsEnabled   B
last analyzed

Complexity

Conditions 7

Size

Total Lines 24
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 7
eloc 14
dl 0
loc 24
rs 8
c 0
b 0
f 0
nop 1
1
package timeago
2
3
import "testing"
4
5
func TestOptionIsEnabled(t *testing.T) {
6
	t.Run("returns true if option is enabled", func(test *testing.T) {
7
		options = []opt{OptNoSuffix}
8
9
		if res := optionIsEnabled(OptNoSuffix); res == false {
10
			test.Error("Result must be true, but got false instead")
11
		}
12
13
		options = []opt{}
14
	})
15
16
	t.Run("returns true if option is enabled with other option", func(test *testing.T) {
17
		options = []opt{OptNoSuffix, OptUpcoming}
18
19
		if res := optionIsEnabled(OptUpcoming); res == false {
20
			test.Error("Result must be true, but got false instead")
21
		}
22
23
		options = []opt{}
24
	})
25
26
	t.Run("returns false if option is disabled", func(test *testing.T) {
27
		if res := optionIsEnabled(OptNoSuffix); res == true {
28
			test.Error("Result must be true, but got false instead")
29
		}
30
	})
31
}
32