diff --git a/spec/heading_anchors.spec.php b/spec/heading_anchors.spec.php new file mode 100644 index 0000000..704b712 --- /dev/null +++ b/spec/heading_anchors.spec.php @@ -0,0 +1,30 @@ +headingAnchors = new HeadingAnchors(); + }); + + it('is registrable', function () { + expect($this->headingAnchors)->toBeAnInstanceOf(\Dxw\Iguana\Registerable::class); + }); + + describe('->register()', function () { + it('adds the filter', function () { + allow('add_filter')->toBeCalled(); + expect('add_filter')->toBeCalled()->once(); + expect('add_filter')->toBeCalled()->with('block_editor_settings_all', [$this->headingAnchors, 'enforceAnchors']); + $this->headingAnchors->register(); + }); + }); + + describe('->enforceAnchors', function () { + it('sets __experimentalGenerateAnchors to true', function () { + $settings = []; + $result = $this->headingAnchors->enforceAnchors($settings); + expect($result['__experimentalGenerateAnchors'])->toEqual(true); + }); + }); +}); diff --git a/src/HeadingAnchors.php b/src/HeadingAnchors.php new file mode 100644 index 0000000..ec2ac69 --- /dev/null +++ b/src/HeadingAnchors.php @@ -0,0 +1,17 @@ +