{DOMUtils} = require 'nylas-exports' BlockquoteManager = require '../../src/components/contenteditable/blockquote-manager' describe "BlockquoteManager", -> outdentCases = ["""
|
""" , """
|
""" , """

\n | """ , """

| """ , """
|
""" , """
|
""" , """

yo

|test """ ] backspaceCases = ["""
yo|
""" , """
yo |
""" , """

  | """ , """

yo | """ , """
yo|
""" , """
yo |
""" , """

yo

yo |test """ ] setupContext = (testCase) -> context = document.createElement("blockquote") context.innerHTML = testCase {node, index} = DOMUtils.findCharacter(context, "|") if not node then throw new Error("Couldn't find where to set Selection") mockSelection = { isCollapsed: true anchorNode: node anchorOffset: index } return mockSelection outdentCases.forEach (testCase) -> it """outdents\n#{testCase}""", -> mockSelection = setupContext(testCase) editor = {currentSelection: -> mockSelection} expect(BlockquoteManager._isInBlockquote(editor)).toBe true expect(BlockquoteManager._isAtStartOfLine(editor)).toBe true backspaceCases.forEach (testCase) -> it """backspaces (does NOT outdent)\n#{testCase}""", -> mockSelection = setupContext(testCase) editor = {currentSelection: -> mockSelection} expect(BlockquoteManager._isInBlockquote(editor)).toBe true expect(BlockquoteManager._isAtStartOfLine(editor)).toBe false