Tests/Following.Test.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
[CmdletBinding()]
param()

$script:moduleRoot = Split-Path $PSScriptRoot -Parent
Import-Module $script:moduleRoot -Force

Connect-Spotify -ClientIdSecret (import-clixml .\Credential.xml) -KeepCredential | out-null

Describe 'Spotify Following Feature' {
    $Artist = Find-SpotifyArtist -Filter "justin Bieber" | select -first 1
    $Playlist = Find-SpotifyPlaylist -Filter "justin Bieber" | select -first 1
    $User = Get-SpotifyProfile -Id "1135956113" | select -first 1

    Context -Name 'Follow Artist' {
        {Follow-SpotifyItem -Type artist -Id $Artist.Id} | should not throw
        Assert-SpotifyFollowing -Type Artist -Id $Artist.id | should be $true
    }

    Context -Name 'Unfollow Artist' {
        {Unfollow-SpotifyItem -Type artist -Id $Artist.Id} | should not throw
        Assert-SpotifyFollowing -Type Artist -Id $Artist.id | should be $false
    }

    Context -Name 'Follow User' {
        {Follow-SpotifyItem -Type user -Id $user.Id} | should not throw
        Assert-SpotifyFollowing -Type User -Id $user.id | should be $true
    }

    Context -Name 'Unfollow User' {
        {Unfollow-SpotifyItem -Type user -Id $user.Id} | should not throw
        Assert-SpotifyFollowing -Type User -Id $user.id | should be $false
    }

    Context -Name 'Follow Playlist' {
        {Follow-SpotifyItem -Type playlist -Id $Playlist.Id -OwnerId $Playlist.owner.id} | should not throw
        Assert-SpotifyFollowing -Type Playlist -Id $Playlist.id -OwnerId $Playlist.owner.id | should be $true
    }

    Context -Name 'Unfollow Artist' {
        {Unfollow-SpotifyItem -Type playlist -Id $Playlist.Id -OwnerId $Playlist.owner.id} | should not throw
        Assert-SpotifyFollowing -Type Playlist -Id $Playlist.id -OwnerId $Playlist.owner.id | should be $false
    }
}