Skip to content

Latest commit

 

History

History
476 lines (446 loc) · 21.6 KB

BEHAVIOR.md

File metadata and controls

476 lines (446 loc) · 21.6 KB

BEHAVIOR.md

This file is generated by context-organizer. Do not edit it manually.

Module: All component and utils should be exported

  • DateTime should be defined
  • Dialog should be defined
  • Form should be defined
  • Input should be defined
  • Observer should be defined
  • useDebounce should be defined
  • useThrottle should be defined

Module: useAI Security

  • should not allow bypass via Object.create in preload
  • should not report an API as available if it is just a plain object

Module: useAI

  • should call onProgress callback during preload
  • should call onReady callback when API becomes available
  • should check only specified APIs
  • should detect LanguageDetector availability
  • should detect Proofreader experimental API availability
  • should detect Prompt API via legacy window.ai.languageModel fallback
  • should detect Rewriter experimental API availability
  • should detect Summarizer availability
  • should detect Translator availability
  • should detect Writer experimental API availability
  • should detect experimental APIs availability
  • should handle errors in availability check
  • should initialize with idle status and all APIs unavailable
  • should preload a specific API
  • should preload all APIs
  • should return false for isAvailable when some APIs are unavailable
  • should return null progress when not downloading

Module: useAIPrompt

  • should call destroy on unmount
  • should fail if user activation is missing
  • should handle append method correctly
  • should handle availability "after-download"
  • should handle contextoverflow event
  • should handle download progress
  • should handle errors during prompting
  • should handle errors in append method
  • should handle multimodal input in prompt
  • should handle streaming with cumulative chunks
  • should initialize with idle status
  • should pass through prompting status when calling prompt
  • should reset state correctly
  • should respect warmup option

Module: useAIProofreader

  • should call destroy on unmount
  • should handle AbortError by resetting to idle
  • should handle download progress
  • should handle errors
  • should initialize with idle status
  • should pass expectedInputLanguages option to Proofreader.create
  • should pass through proofreading status when calling proofread
  • should prevent concurrent proofreading
  • should reset state correctly
  • should respect warmup option
  • should return corrected text and corrections
  • should work without options parameter

Module: useAIRewriter

  • should call destroy on unmount
  • should handle download progress
  • should handle errors
  • should handle streaming
  • should initialize with idle status
  • should pass context parameter to rewrite method
  • should pass expectedContextLanguages option to Rewriter.create
  • should pass expectedInputLanguages option to Rewriter.create
  • should pass format option to Rewriter.create
  • should pass length option to Rewriter.create
  • should pass outputLanguage option to Rewriter.create
  • should pass overrideTone parameter to rewrite method
  • should pass sharedContext option to Rewriter.create
  • should pass through rewriting status when calling rewrite
  • should pass tone option to Rewriter.create
  • should prevent concurrent rewriting
  • should reset state correctly
  • should respect warmup option
  • should work without options parameter

Module: useAISummarize

  • should call destroy on unmount
  • should default to "auto" for outputLanguage
  • should fail if user activation is missing
  • should fall back to "en" when language detection is unavailable
  • should handle download progress
  • should handle errors
  • should handle outputLanguage "auto" by detecting language from text
  • should handle outputLanguage "user" by using browser language
  • should handle streaming
  • should initialize with idle status
  • should pass expectedContextLanguages option to Summarizer.create
  • should pass expectedInputLanguages option to Summarizer.create
  • should pass format option to Summarizer.create
  • should pass length option to Summarizer.create
  • should pass preference option to Summarizer.create
  • should pass sharedContext option to Summarizer.create
  • should pass through summarizing status when calling summarize
  • should pass type option to Summarizer.create
  • should prevent concurrent summarization
  • should respect warmup option
  • should work without options parameter

Module: useAIWrite

  • should call destroy on unmount
  • should handle download progress
  • should handle errors
  • should handle streaming
  • should initialize with idle status
  • should pass context parameter to write method
  • should pass expectedContextLanguages option to Writer.create
  • should pass expectedInputLanguages option to Writer.create
  • should pass format option to Writer.create
  • should pass length option to Writer.create
  • should pass outputLanguage option to Writer.create
  • should pass sharedContext option to Writer.create
  • should pass through writing status when calling write
  • should pass tone option to Writer.create
  • should prevent concurrent writing
  • should reset state correctly
  • should respect warmup option
  • should work without options parameter

Module: useDebounce

  • should clear timeout on unmount
  • should only update to the latest value after rapid updates
  • should return the debounced value when delay is 0
  • should update the value after the specified delay
  • should use default delay of 500ms when no delay is provided

Module: useLanguageDetection

  • should auto-detect when text is provided
  • should calculate isUserLang as false when languages differ
  • should calculate isUserLang correctly when languages match
  • should filter by minConfidence
  • should handle download progress
  • should handle empty text
  • should handle errors
  • should initialize with idle status
  • should limit by maxResults
  • should not auto-detect when enable is false
  • should reset state
  • should respect warmup option

Module: useList Security

  • should NOT allow matching items via restricted keys even with undefined value
  • should NOT allow toggling items via restricted keys (it should always add)
  • should not allow matching items via proto
  • should not allow matching items via prototype properties like constructor
  • should not allow matching items via toString

Module: useList

  • should add a primitive item if it is not in the list
  • should add an item to an empty list
  • should add an item to the beginning of the list
  • should add an item to the end of the list
  • should add an object if it is not in the list (by key)
  • should add an object if it is not in the list (by reference)
  • should add multiple items to an empty list
  • should add multiple items to the beginning of the list
  • should add multiple items to the end of the list by default
  • should always add if key is restricted
  • should do nothing and keep same reference for empty list
  • should do nothing and keep same reference for offset 0
  • should do nothing and keep same reference for single item list
  • should do nothing if all items are already unique
  • should do nothing if any index is out of bounds
  • should do nothing if fromIndex is out of bounds
  • should do nothing if indices are identical
  • should do nothing if key is provided but item is not an object
  • should do nothing if no item matches the condition
  • should do nothing if no item matches the predicate
  • should do nothing if the index is out of bounds
  • should do nothing if the input array is empty or not an array
  • should do nothing if toIndex is out of bounds
  • should do nothing on an empty list
  • should find all items matching key and value for objects
  • should find all items matching value for primitives when key is null/undefined
  • should find the first item matching key and value for objects
  • should find the first item matching value for primitives when key is null/undefined
  • should find the index of the first item matching key and value for objects
  • should find the index of the first item matching value for primitives when key is null/undefined
  • should handle a single item list
  • should handle an empty list
  • should handle equal values during sort
  • should handle offset larger than list length
  • should initialize with an empty list if no initial list is provided
  • should initialize with the provided initial list
  • should insert an item at the specified index
  • should insert at the beginning (index 0)
  • should insert at the beginning if index is less than 0
  • should insert at the end (index equals length)
  • should insert at the end if index is greater than length
  • should insert into an empty list
  • should insert multiple items at the beginning (index 0)
  • should insert multiple items at the specified index
  • should move an item backward in the list
  • should move an item forward in the list
  • should move an item to the same position without change
  • should push null and undefined values to the end of the list
  • should remove a primitive item if it is in the list
  • should remove all items from the list
  • should remove all items matching key and value for objects
  • should remove all items matching value for primitives when key is null/undefined
  • should remove an object if it is in the list (by key)
  • should remove an object if it is in the list (by reference)
  • should remove duplicate objects by key
  • should remove duplicate objects by reference
  • should remove duplicate primitives
  • should remove items based on index
  • should remove items matching the predicate
  • should remove the first item (index 0)
  • should remove the first item matching key and value for objects
  • should remove the first item matching value for primitives when key is null/undefined
  • should remove the item at the specified index
  • should remove the last item (last index)
  • should reorder the list items
  • should replace the list using an updater function
  • should replace the list with a new array
  • should return -1 if no item matches the condition
  • should return -1 on an empty list
  • should return 0 for an empty list if a predicate is provided
  • should return 0 for an empty list if no predicate is provided
  • should return 0 if the predicate matches no items
  • should return a new array instance when setting a direct empty array
  • should return a new array instance when the list changes
  • should return a new array instance when using updater function, even if content is same
  • should return a new list instance
  • should return a new list instance even if sort order remains same
  • should return a new list instance even if the updateFn returns the original item
  • should return a new list instance if a match was found, even if the updateFn returns the original item instance
  • should return a new list instance if any match was found, even if updateFn returns original item for some or all matches
  • should return a new list instance on successful swap
  • should return a new list instance when reversed
  • should return a new list instance when rotated
  • should return an empty array if no item matches the condition
  • should return an empty array on an empty list
  • should return false if no item matches the condition
  • should return false on an empty list
  • should return the number of items matching the predicate
  • should return the total number of items if no predicate is provided
  • should return true if an item matches key and value for objects
  • should return true if an item matches value for primitives when key is null/undefined
  • should return undefined if no item matches the condition
  • should return undefined on an empty list
  • should reverse a list of objects
  • should reverse the order of items in the list
  • should rotate the list items to the left with a negative offset
  • should rotate the list items to the right with a positive offset
  • should sort the list by key in ascending order
  • should sort the list by key in descending order
  • should sort the list in descending order for primitives
  • should sort the list with a custom compare function
  • should sort the list with default sort order (ascending)
  • should swap two items in the list
  • should update a primitive item if it is in the list
  • should update all items matching key and value for objects
  • should update all items matching value for primitives when key is null/undefined
  • should update an object if it is in the list (by key)
  • should update an object if it is in the list (by reference)
  • should update items based on index
  • should update items matching the predicate
  • should update the first item matching key and value for objects
  • should update the first item matching value for primitives when key is null/undefined
  • should update the item at index 0 for primitives
  • should update the item at the specified index

Module: useThrottle

  • should eventually update to the latest value (trailing edge)
  • should return the value immediately when limit is 0
  • should throttle updates
  • should update immediately if the limit has passed
  • should update the value immediately on the first call
  • should use default limit of 500ms when not provided

Module: useTimer security reproduction

  • should handle invalid Date in setTimeout and not cause infinite loop/NaN progress

Module: useTimer

  • should calculate remaining time correctly for setTimeout
  • should call onCancelTimer when a limited interval completes naturally
  • should clean up all timers on unmount
  • should clear a timer before it completes
  • should clear progress tracking if timer is cleared while progress is pending
  • should create a timer with setTimeout
  • should execute limited intervals the specified number of times
  • should execute setInterval repeatedly
  • should handle NaN numeric delays in setTimeout by defaulting to 0ms
  • should handle invalid Date objects in setTimeoutDate by defaulting to 0ms
  • should handle negative delays in setTimeout by executing immediately
  • should handle negative duration in setupProgressTracking
  • should handle setting a new timer while one is already active
  • should handle timeouts with Date objects
  • should not report progress if onProgress callback is not provided
  • should report progress for long timeouts
  • should return -1 for remaining time for non-active states or intervals
  • should return null for remaining iterations for non-limited intervals/timeouts
  • should trigger onSetTimer callback in setInterval
  • should trigger onSetTimer callback in setLimitedInterval
  • should warn and default to 1000ms if setInterval is called with NaN
  • should warn and default to 1000ms if setLimitedInterval is called with NaN
  • should warn and default to 1000ms if setLimitedInterval is called with a Date object
  • should warn but still work when providing Date object to setInterval
  • should warn if setLimitedInterval is called with invalid iterations

Module: useTranslator

  • should auto-translate when text is provided
  • should detect source language when sourceLanguage is auto
  • should handle download progress
  • should handle errors
  • should handle streaming
  • should initialize with idle status
  • should initialize with idle status and default options
  • should not auto-translate when enable is false
  • should reset state
  • should respect warmup option
  • should skip translation when source and target are the same
  • should translate text successfully
  • should use user language when targetLanguage is user

Module: iso2LocalDateTime security

  • should handle dates that would cause RangeError in toISOString after offset
  • should return original date if toISOString throws

Module: iso2LocalDateTime

  • should convert ISO date-time string to local date-time string
  • should handle different time zones correctly
  • should handle empty string
  • should handle end of year correctly
  • should return '12345' for invalid input: 12345
  • should return 'invalid date string' for invalid input: invalid date string
  • should return 'null' for invalid input: null
  • should return 'undefined' for invalid input: undefined
  • should return the original date if the adjusted date is invalid
  • should return the original date if toISOString fails

Module: isRestrictedKey

  • should be case sensitive
  • should handle empty string
  • should return false for non-restricted keys
  • should return true for all restricted keys

Module: valueTransforms

  • should apply sequential transforms from an array
  • should capitalize the string
  • should handle all-caps in camelCase and pascalCase
  • should handle empty strings
  • should handle multiple words in capitalize (only first char of first word)
  • should handle strings with multiple spaces
  • should lowercase other characters in capitalize
  • should remove all non-alphanumeric characters
  • should remove all non-letter characters
  • should remove all non-numeric characters
  • should remove invalid email characters
  • should return the original value if an invalid transform is provided
  • should return the original value if no transform is provided
  • should transform to camel case
  • should transform to kebab case
  • should transform to lower case
  • should transform to pascal case
  • should transform to slug case
  • should transform to snake case
  • should transform to title case
  • should transform to upper case

Module: getUserLanguage

  • should handle language codes with region and script
  • should handle simple language codes without region
  • should prefer navigator.language over navigator.languages
  • should return "en" when navigator is undefined
  • should return "en" when navigator.language is not available
  • should return "en" when navigator.languages is an empty array
  • should return normalized language code from navigator.language
  • should return normalized language code from navigator.languages[0]

Module:

  • should call reload when pending function is called
  • should clean up properly on unmount
  • should handle null as a valid success value
  • should handle pending state as a function
  • should handle timeout
  • should handle timeout error branch when unmounted
  • should not call onError if unmounted before timeout expires
  • should not call onSuccess if unmounted before promise resolves
  • should reload the promise when reload is called
  • should render error state and call onError
  • should render pending state
  • should render success state and call onSuccess

Module:

  • should call onChange & onChangeISOValue when user changes date input
  • should forward ref to the underlying input element
  • should pass debounceDelay prop to Input (inherited)
  • should pass transform prop to Input (inherited)
  • should pass transformFn prop to Input (inherited)
  • should render datalist prop (inherited from Input)
  • should render label prop (inherited from Input)
  • should render the DateTime component
  • should support ISO strings for min and max props
  • should update the input value when props.isoValue changes (controlled component support)

Module: DateTime Security

  • should not crash if invalid date is provided via props
  • should not crash if invalid date is provided via user input
  • should still work for valid dates

Module: Dialog

  • should call close when isOpen changes to false
  • should call onClose and update internal state when closed via native event
  • should call onClose callback when closed via prop change
  • should call onOpen callback when opened
  • should call show when isOpen is true and behavior is dialog
  • should call showModal when isOpen is true and behavior is modal
  • should close on backdrop click when closeOnBackdropClick is true
  • should not redundantly call native methods when re-rendered with new callback instances
  • should pass native dialog element props via spread
  • should render correctly with children
  • should toggle dialog when opener is clicked

Module: Form Component

  • should call onSubmit with form values on submit
  • should call onSubmitValues with form values on submit
  • should filter out empty values if filterEmptyValues is true
  • should filter out restricted keys to prevent prototype pollution and injection
  • should forward ref to the form element
  • should include empty values by default (filterEmptyValues is false)
  • should render the form and its children

Module: Form Security

  • should ignore dangerous keys to prevent prototype pollution

Module:

  • should apply multiple transforms from array
  • should apply multiple transforms in sequence
  • should call onChange, onChangeValue & onChangeDebounce when input value changes
  • should call transformFn when provided
  • should forward ref to the input element
  • should render a datalist with options when provided
  • should render a label when provided
  • should render an input element
  • should transform value to uppercase when transform prop is provided
  • should update the input value when props.value changes (controlled component support)
  • should work with empty array

Module: LazyRender Component

  • should pass IntersectionObserver options correctly
  • should pass root prop to IntersectionObserver
  • should pass rootMargin prop to IntersectionObserver
  • should render children when it appears in view
  • should render placeholder by default (when not visible)
  • should unrender children and show placeholder when it disappears from view
  • should use the default div wrapper when not specified
  • should use the specified wrapper element

Module: Observer Component

  • should call IntersectionObserver with the provided options
  • should call onAppear when element enters viewport
  • should call onDisappear when element leaves viewport
  • should handle both onAppear and onDisappear callbacks
  • should not call onAppear when isIntersecting is false
  • should not call onDisappear when isIntersecting is true
  • should not recreate IntersectionObserver when callbacks change
  • should observe the ref element when mounted
  • should pass root prop to IntersectionObserver
  • should pass rootMargin prop to IntersectionObserver
  • should render children correctly
  • should unobserve when unmounted
  • should use the default div wrapper when not specified
  • should use the latest callback even if it changes after mount
  • should use the specified wrapper element