Chapter 5: Customizing Your Bedtime Story
Overview
Coming soon…
Training
Pre-requisites
Concepts Covered in This Chapter
Tools Used in This Chapter
Commands Used in This Chapter
Assertions
assert.is.truthy
- Ensures that a given value is truthy (not null or undefined).
assert.is.true
- Validates that a condition is true.
assert.is.equal
- Checks if two values are equal.
assert.is.deep.equal
- Verifies that complex or nested objects are deeply equal.
assert.throws
- Confirms that an error is thrown during a specific operation.
form assert.card.renders.form
- Checks if a form is correctly rendered inside a card.
form assert.renders.field
- Verifies that a specific field is rendered in a form.
form assert.field.renders.as
- Confirms the type of UI element rendered for a field (e.g., select, text area).
form assert.field.renders.options
- Validates the rendering of expected choices/options for a select field.
Routing
router.redirect
- Redirects the user to a different SkillView or route.
this.router
- Accesses routing methods and helpers within the current view.
Event Handling
eventFaker.fake
- Fakes events such as
did.generate.story
,list.family.members
, orcurrent.challenge
.
- Fakes events such as
eventFaker.on
- Sets up event listeners for testing purposes.
client.emit
- Sends a specific event to the backend for processing.
client.emit.and.flatten.responses
- Emits an event and flattens the response for simpler handling.
View Controller Lifecycle
public async load
- Lifecycle method used to initialize view controllers and pass in route parameters.
View Controller and Form Management
formVC.get.values
- Retrieves values from the form.
formVC.render
- Renders a form dynamically based on a schema.
this.load()
- Triggers the load lifecycle manually.
this.views.setController
- Sets a specific view controller for a view.
controller.Factory
- Instantiates a new view controller.
get.form.VC
- Returns the internal form view controller.
get.card.VC
- Retrieves the card view controller from within another component.
Schemas and Forms
build.schema
- Defines a schema with ID, type, and required fields.
build.form
- Uses a schema to generate a complete form definition.
form schema.sections.fields
- Declares the layout and rendering options of form fields.
Testing Utilities
test.static.async
- Declares async test cases that can be reused across tests.
spy.class.extends
- Used to create test doubles by extending base controllers.
get.view.controller
- Retrieves a stub or real controller for test inspection.
get.should.render.submit.controls
- Checks whether form-level submit buttons are visible or hidden.
Other Utilities
generate.id
- Generates a random unique ID for use in mock data or schemas.
extract.schema.to.module.scope
- Refactors schema definitions for reuse across the module.
render.as.select
- Renders a field as a multi-select dropdown.
is.array.true
- Declares a field as supporting multiple selections.
form.card.view.controller
- Wraps both form and card into a reusable controller.