Skip to content

Commit 680b726

Browse files
Add test case
Signed-off-by: Gabriel Adrian Samfira <[email protected]>
1 parent 86bb4d6 commit 680b726

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

Tests/powershell-yaml.Tests.ps1

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2016-2024 Cloudbase Solutions Srl
1+
# Copyright 2016-2024 Cloudbase Solutions Srl
22
#
33
# Licensed under the Apache License, Version 2.0 (the "License"); you may
44
# not use this file except in compliance with the License. You may obtain
@@ -190,6 +190,22 @@ children:
190190
}
191191

192192
Describe "Test PSCustomObject wrapped values are serialized correctly" {
193+
Context "A PSCustomObject that contains an array of PSObjects" {
194+
It "Should serialize correctly" {
195+
$expected = @"
196+
yamlList:
197+
- item1
198+
- item2
199+
200+
"@
201+
$data = ConvertFrom-YAml "yamlList: []" | ConvertTo-JSON -Depth 3 | ConvertFrom-Json
202+
$jsData = '["item1", "item2"]'
203+
$data.yamlList = $jsData | ConvertFrom-Json
204+
205+
$asYaml = ConvertTo-Yaml $data
206+
Assert-Equivalent -Options $compareStrictly -Expected $expected -Actual $asYaml
207+
}
208+
}
193209
Context "A PSCustomObject containing nested PSCustomObjects" {
194210
It "Should serialize correctly" {
195211
$expectBigInt = [System.Numerics.BigInteger]::Parse("9999999999999999999999999999999999999999999999999")

0 commit comments

Comments
 (0)