React Wiring Library

React Wiring Library

  • Docs
  • API
  • GitHub

›API Reference

Introduction

  • Getting Started

Basic Tutorials

  • Prepping Components
  • Basic Wiring Structure
  • Building Readable Snapshots
  • Testing Interactions

Advanced Tutorials

  • Using Extend To Make Tests DRY

API Reference

  • getRender
  • Wiring Tree
  • Wiring Node
  • Abstract Wiring Node
  • find{childNode}

Wiring Tree

Structure

A Wiring Tree consists of a root node with wiring nodes beneath it.

{
  children: {
    todoList: {
      findValue: 'todo-list',
      serialize: (val, {todoStrings, combine}) => combine(...todoStrings),
      children: {
        todo: {
          isMultiple: true,
          findValue: 'todo',
          serialize: (val, {checkBoxString}) => {
            return `${checkBoxString}${val ? val.textContent : ''}$`
          },
          children: {
            checkbox: {
              findValue: 'checkbox',
              serialize: val => (val.checked ? '☑️' : '◻️'),
            },
          },
        },
      },
    },
    otherComponent: {
        ...
    }
  },
}

The Root Node

The root node is the only node in the wiring tree that does not correspond to an actual dom node. It has two main roles within the tree.

1. Only it's direct children can be serialized

If an object needs to be serialized using serialize or toMatchSnapshot make sure that's its declared as a direct child of the root.

2. It allows new functionality to be returned from render

If you provide extend to the root node, everything returned from extend will also be returned from render

All of the following properties are invalid on a root node

  • findValue / findType
  • getCurrentType
  • types
  • isMultiple
  • shouldFindInBaseElement
  • serialize
← getRenderWiring Node →
  • Structure
  • The Root Node
    • 1. Only it's direct children can be serialized
    • 2. It allows new functionality to be returned from render
React Wiring Library
Docs
Getting StartedBasic TutorialsAPI
More
GitHubStar
Copyright © 2019 Clay Branch