src/Validator.tests.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
Import-Module $PSScriptRoot/Validator.psm1 -Force  # force code to be reloaded
Describe 'Validator' {
    Context "Simple rule" {
        It '-Lowercase is allowed' {
            {Confirm-Arguments "Site.org" -Lowercase} | Should -Not -Throw
        }
        It '-Uppercase is allowed' {
            {Confirm-Arguments "Site.org" -Uppercase} | Should -Not -Throw
        }
        It '-Digits is allowed' {
            {Confirm-Arguments "Site.org" -Digits} | Should -Not -Throw
        }
        It '-Symbols is allowed' {
            {Confirm-Arguments "Site.org" -Symbols} | Should -Not -Throw
        }
        It '-NoLowercase is allowed' {
            {Confirm-Arguments "Site.org" -NoLowercase} | Should -Not -Throw
        }
        It '-NoUppercase is allowed' {
            {Confirm-Arguments "Site.org" -NoUppercase} | Should -Not -Throw
        }
        It '-NoDigits is allowed' {
            {Confirm-Arguments "Site.org" -NoDigits} | Should -Not -Throw
        }
        It '-NoSymbols is allowed' {
            {Confirm-Arguments "Site.org" -NoSymbols} | Should -Not -Throw
        }
    }
    Context "Opposite rules" {
        It '-Lowercase and -NoLowercase are not allowed together' {
            {Confirm-Arguments "Site.org" -Lowercase -NoLowercase} | Should -Throw
        }
        It '-Uppercase and -NoUppercase are not allowed together' {
            {Confirm-Arguments "Site.org" -Uppercase -NoUppercase} | Should -Throw
        }
        It '-Digits and -NoDigits are not allowed together' {
            {Confirm-Arguments "Site.org" -Digits -NoDigits} | Should -Throw
        }
        It '-Symbols and -NoSymbols are not allowed together' {
            {Confirm-Arguments "Site.org" -Symbols -NoSymbols} | Should -Throw
        }
    }

    Context "`Site` argument is required" {
        It 'when no argument provided' {
            {Confirm-Arguments} | Should -Throw
        }
        It 'when various arguments provided' {
            {Confirm-Arguments -Symbols -Lowercase -Uppercase -Digits} | Should -Throw
        }
    }

    Context "-Prompt argument" {
        It "make `Site` argument optional" {
            {Confirm-Arguments -Prompt} | Should -Not -Throw
        }
    }

    Context "copy to clipboard" {
        It "is possible" {
            {Confirm-Arguments "Site.org" -Clipboard} | Should -Not -Throw
        }
    }
}