Skip to content

Commit

Permalink
Merge pull request #6 from netglue/filter-link-attributes
Browse files Browse the repository at this point in the history
Any link `config.select` should be null when unset
  • Loading branch information
gsteel committed Sep 2, 2021
2 parents a7fbd25 + 61471d6 commit 8b6308c
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 8 deletions.
22 changes: 22 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,28 @@

All notable changes to this project will be documented in this file, in reverse chronological order by release.

## 0.4.1 - 2021-09-02

### Added

- Nothing.

### Changed

- [#6](https://github.com/netglue/prismic-cli/pull/6) adds config.select = null to links that do not have to be a specific type to match the structure returned from the api. This helps to reduce noise in diffs…

### Deprecated

- Nothing.

### Removed

- Nothing.

### Fixed

- Nothing.

## 0.4.0 - 2021-09-02

### Added
Expand Down
12 changes: 4 additions & 8 deletions src/TypeBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,16 +111,10 @@ public static function documentLink(string $label, ?string $placeholder = null,
'select' => 'document',
'label' => $label,
'placeholder' => $placeholder,
'customtypes' => $customTypes,
'tags' => $tags,
]);

if (! empty($customTypes)) {
$config['customtypes'] = $customTypes;
}

if (! empty($tags)) {
$config['tags'] = $tags;
}

return [
'type' => self::TYPE_LINK,
'config' => $config,
Expand All @@ -137,6 +131,8 @@ public static function link(string $label, ?string $placeholder = null, bool $al
'customtypes' => empty($customTypes) ? null : $customTypes,
]);

$config['select'] = null;

return [
'type' => self::TYPE_LINK,
'config' => $config,
Expand Down
25 changes: 25 additions & 0 deletions test/Unit/TypeBuilderTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

declare(strict_types=1);

namespace PrimoTest\Cli\Unit;

use PHPUnit\Framework\TestCase;
use Primo\Cli\TypeBuilder as T;

class TypeBuilderTest extends TestCase
{
public function testLinkConfigHasExpectedStructure(): void
{
$data = T::link('Label', 'Placeholder', false, null);
$expect = [
'type' => T::TYPE_LINK,
'config' => [
'select' => null,
'label' => 'Label',
'placeholder' => 'Placeholder',
],
];
self::assertEquals($expect, $data);
}
}

0 comments on commit 8b6308c

Please sign in to comment.