<commit_before>import { expect } from 'chai'
import Up from '../../../index'
import { insideDocumentAndParagraph } from '../Helpers'
import { ImageNode } from '../../../SyntaxNodes/ImageNode'
import { AudioNode } from '../../../SyntaxNodes/AudioNode'
import { VideoNode } from '../../../SyntaxNodes/VideoNode'
import { SpoilerNode } from '../../../SyntaxNodes/SpoilerNode'
import { NsfwNode } from '../../../SyntaxNodes/NsfwNode'
import { NsflNode } from '../../../SyntaxNodes/NsflNode'
import { FootnoteNode } from '../../../SyntaxNodes/FootnoteNode'
import { FootnoteBlockNode } from '../../../SyntaxNodes/FootnoteBlockNode'
import { LinkNode } from '../../../SyntaxNodes/LinkNode'
import { ParagraphNode } from '../../../SyntaxNodes/ParagraphNode'
import { PlainTextNode } from '../../../SyntaxNodes/PlainTextNode'
import { DocumentNode } from '../../../SyntaxNodes/DocumentNode'

const up = new Up({
  baseForUrlsStartingWithHashMark: 'https://example.com/page'
})


describe('The "baseForUrlsStartingWithFragmentIdentifier" config setting', () => {
  it('is prefixed to link URLs that start with a hash mark ("#")', () => {
    const text = '[Chrono Cross](#wiki/Chrono_Chross)'

    expect(up.toAst(text)).to.be.eql(
      insideDocumentAndParagraph([
        new LinkNode([
          new PlainTextNode('Chrono Cross')
        ], 'https://example.com/page#wiki/Chrono_Chross')
      ])
    )
  })

  it('is prefixed to image URLs that start with a hash mark', () => {
    const text = '[image: Chrono Cross logo](#cc-logo.png)'

    expect(up.toAst(text)).to.be.eql(
      new DocumentNode([
        new ImageNode('Chrono Cross logo', 'https://example.com/page#cc-logo.png')
      ])
    )
  })

  it('is prefixed to audio URLs that start with a hash mark', () => {
    const text = '[audio: Chrono Cross ending theme](#radical dreamers.mp3)'

    expect(up.toAst(text)).to.be.eql(
      new DocumentNode([
        new AudioNode('Chrono Cross ending theme', 'https://example.com/page#radical dreamers.mp3')
      ])
    )
  })

  it('is prefixed to video URLs that start with a hash mark', () => {
    const text = '[video: Chrono Cross ending cinematic][#radical dreamers.webm]'

    expect(up.toAst(text)).to.be.eql(
      new DocumentNode([
        new VideoNode('Chrono Cross ending cinematic', 'https://example.com/page#radical dreamers.webm')
      ])
    )
  })

  it('is prefixed to linkified spoiler URLs that start with a hash mark', () => {
    const text = '<NAME> produces [SPOILER: Blue Sky meth](#wiki/Blue_Sky)'

    expect(up.toAst(text)).to.be.eql(
      insideDocumentAndParagraph([
        new PlainTextNode('Walter White produces '),
        new SpoilerNode([
          new LinkNode([
            new PlainTextNode('Blue Sky meth')
          ], 'https://example.com/page#wiki/Blue_Sky')
        ])
      ])
    )
  })

  it('is prefixed to linkified NSFW URLs that start with a hash mark', () => {
    const text = 'Walter White produces [NSFW: Blue Sky meth](#wiki/Blue_Sky)'

    expect(up.toAst(text)).to.be.eql(
      insideDocumentAndParagraph([
        new PlainTextNode('Walter White produces '),
        new NsfwNode([
          new LinkNode([
            new PlainTextNode('Blue Sky meth')
          ], 'https://example.com/page#wiki/Blue_Sky')
        ])
      ])
    )
  })

  it('is prefixed to linkified NSFL URLs that start with a hash mark', () => {
    const text = 'Walter White produces [NSFL: Blue Sky meth](#wiki/Blue_Sky)'

    expect(up.toAst(text)).to.be.eql(
      insideDocumentAndParagraph([
        new PlainTextNode('Walter White produces '),
        new NsflNode([
          new LinkNode([
            new PlainTextNode('Blue Sky meth')
          ], 'https://example.com/page#wiki/Blue_Sky')
        ])
      ])
    )
  })

  it("is prefixed to linkified footnote URLs that start with a hash mark", () => {
    const text = "I don't eat cereal. (^Well, I eat one.)[#cereals/lucky-charms?show=nutrition] Never have."

    const footnote = new FootnoteNode([
      new LinkNode([
        new PlainTextNode('Well, I eat one.')
      ], 'https://example.com/page#cereals/lucky-charms?show=nutrition')
    ], 1)

    expect(up.toAst(text)).to.be.eql(
      new DocumentNode([
        new ParagraphNode([
          new PlainTextNode("I don't eat cereal."),
          footnote,
          new PlainTextNode(" Never have."),
        ]),
        new FootnoteBlockNode([footnote])
      ]))
  })

  it('is prefixed to link URLs that start with a hash mark when the link content and URL are separated by whitespace', () => {
    const text = '[Chrono Cross] (#wiki/Chrono_Chross)'

    expect(up.toAst(text)).to.be.eql(
      insideDocumentAndParagraph([
        new LinkNode([
          new PlainTextNode('Chrono Cross')
        ], 'https://example.com/page#wiki/Chrono_Chross')
      ])
    )
  })

  it('is prefixed to linkified spoiler URLs that start with a hash mark when the spoiler part and the URL are separated by whitespace', () => {
    const text = '<NAME> produces [SPOILER: Blue Sky meth] (#wiki/Blue_Sky)'

    expect(up.toAst(text)).to.be.eql(
      insideDocumentAndParagraph([
        new PlainTextNode('<NAME> produces '),
        new SpoilerNode([
          new LinkNode([
            new PlainTextNode('Blue Sky meth')
          ], 'https://example.com/page#wiki/Blue_Sky')
        ])
      ])
    )<commit_msg>Add 3 failing tests<commit_after>import { expect } from 'chai'
import Up from '../../../index'
import { insideDocumentAndParagraph } from '../Helpers'
import { ImageNode } from '../../../SyntaxNodes/ImageNode'
import { AudioNode } from '../../../SyntaxNodes/AudioNode'
import { VideoNode } from '../../../SyntaxNodes/VideoNode'
import { SpoilerNode } from '../../../SyntaxNodes/SpoilerNode'
import { NsfwNode } from '../../../SyntaxNodes/NsfwNode'
import { NsflNode } from '../../../SyntaxNodes/NsflNode'
import { FootnoteNode } from '../../../SyntaxNodes/FootnoteNode'
import { FootnoteBlockNode } from '../../../SyntaxNodes/FootnoteBlockNode'
import { LinkNode } from '../../../SyntaxNodes/LinkNode'
import { ParagraphNode } from '../../../SyntaxNodes/ParagraphNode'
import { PlainTextNode } from '../../../SyntaxNodes/PlainTextNode'
import { DocumentNode } from '../../../SyntaxNodes/DocumentNode'

const up = new Up({
  baseForUrlsStartingWithHashMark: 'https://example.com/page'
})


describe('The "baseForUrlsStartingWithFragmentIdentifier" config setting', () => {
  it('is prefixed to link URLs that start with a hash mark ("#")', () => {
    const text = '[Chrono Cross](#wiki/Chrono_Chross)'

    expect(up.toAst(text)).to.be.eql(
      insideDocumentAndParagraph([
        new LinkNode([
          new PlainTextNode('Chrono Cross')
        ], 'https://example.com/page#wiki/Chrono_Chross')
      ])
    )
  })

  it('is prefixed to image URLs that start with a hash mark', () => {
    const text = '[image: Chrono Cross logo](#cc-logo.png)'

    expect(up.toAst(text)).to.be.eql(
      new DocumentNode([
        new ImageNode('Chrono Cross logo', 'https://example.com/page#cc-logo.png')
      ])
    )
  })

  it('is prefixed to audio URLs that start with a hash mark', () => {
    const text = '[audio: Chrono Cross ending theme](#radical dreamers.mp3)'

    expect(up.toAst(text)).to.be.eql(
      new DocumentNode([
        new AudioNode('Chrono Cross ending theme', 'https://example.com/page#radical dreamers.mp3')
      ])
    )
  })

  it('is prefixed to video URLs that start with a hash mark', () => {
    const text = '[video: Chrono Cross ending cinematic][#radical dreamers.webm]'

    expect(up.toAst(text)).to.be.eql(
      new DocumentNode([
        new VideoNode('Chrono Cross ending cinematic', 'https://example.com/page#radical dreamers.webm')
      ])
    )
  })

  it('is prefixed to linkified spoiler URLs that start with a hash mark', () => {
    const text = '<NAME> produces [SPOILER: Blue Sky meth](#wiki/Blue_Sky)'

    expect(up.toAst(text)).to.be.eql(
      insideDocumentAndParagraph([
        new PlainTextNode('<NAME> produces '),
        new SpoilerNode([
          new LinkNode([
            new PlainTextNode('Blue Sky meth')
          ], 'https://example.com/page#wiki/Blue_Sky')
        ])
      ])
    )
  })

  it('is prefixed to linkified NSFW URLs that start with a hash mark', () => {
    const text = '<NAME> produces [NSFW: Blue Sky meth](#wiki/Blue_Sky)'

    expect(up.toAst(text)).to.be.eql(
      insideDocumentAndParagraph([
        new PlainTextNode('<NAME> produces '),
        new NsfwNode([
          new LinkNode([
            new PlainTextNode('Blue Sky meth')
          ], 'https://example.com/page#wiki/Blue_Sky')
        ])
      ])
    )
  })

  it('is prefixed to linkified NSFL URLs that start with a hash mark', () => {
    const text = '<NAME> produces [NSFL: Blue Sky meth](#wiki/Blue_Sky)'

    expect(up.toAst(text)).to.be.eql(
      insideDocumentAndParagraph([
        new PlainTextNode('<NAME> produces '),
        new NsflNode([
          new LinkNode([
            new PlainTextNode('Blue Sky meth')
          ], 'https://example.com/page#wiki/Blue_Sky')
        ])
      ])
    )
  })

  it("is prefixed to linkified footnote URLs that start with a hash mark", () => {
    const text = "I don't eat cereal. (^Well, I eat one.)[#cereals/lucky-charms?show=nutrition] Never have."

    const footnote = new FootnoteNode([
      new LinkNode([
        new PlainTextNode('Well, I eat one.')
      ], 'https://example.com/page#cereals/lucky-charms?show=nutrition')
    ], 1)

    expect(up.toAst(text)).to.be.eql(
      new DocumentNode([
        new ParagraphNode([
          new PlainTextNode("I don't eat cereal."),
          footnote,
          new PlainTextNode(" Never have."),
        ]),
        new FootnoteBlockNode([footnote])
      ]))
  })

  it('is prefixed to linkified audio URLs that start with a hash mark', () => {
    const text = 'Walter White produces [audio: Blue Sky meth](https://blueskymeth/sizzling.ogg)(#wiki/Blue_Sky)'

    expect(up.toAst(text)).to.be.eql(
      insideDocumentAndParagraph([
        new PlainTextNode('Walter White produces '),
        new LinkNode([
          new AudioNode('Blue Sky meth', 'https://blueskymeth/sizzling.ogg')
        ], 'https://example.com/page#wiki/Blue_Sky')
      ])
    )
  })

  it('is prefixed to linkified image URLs that start with a hash mark', () => {
    const text = 'Walter White produces [image: Blue Sky meth](https://blueskymeth/sizzling.png)(#wiki/Blue_Sky)'

    expect(up.toAst(text)).to.be.eql(
      insideDocumentAndParagraph([
        new PlainTextNode('Walter White produces '),
        new LinkNode([
          new ImageNode('Blue Sky meth', 'https://blueskymeth/sizzling.png')
        ], 'https://example.com/page#wiki/Blue_Sky')
      ])
    )
  })

  it('is prefixed to linkified video URLs that start with a hash mark', () => {
    const text = 'Walter White produces [video: Blue Sky meth](https://blueskymeth/sizzling.webm)(#wiki/Blue_Sky)'

    expect(up.toAst(text)).to.be.eql(
      insideDocumentAndParagraph([
        new PlainTextNode('Walter White produces '),
        new LinkNode([
          new VideoNode('Blue Sky meth', 'https://blueskymeth/sizzling.webm')
        ], 'https://example.com/page#wiki/Blue_Sky')
      ])
    )
  })

  it('is prefixed to link URLs that start with a hash mark when the link content and URL are separated by whitespace', () => {
    const text = '[Chrono Cross] (#wiki/Chrono_Chross)'

    expect(up.toAst(text)).to.be.eql(
      insideDocumentAndParagraph([
        new LinkNode([
          new PlainTextNode('Chrono Cross')
        ], 'https://example.com/page#wiki/Chrono_Chross')
      ])
    )
  })

  it('is prefixed to linkified spoiler URLs that start with a hash mark when the spoiler part and the URL are separated by whitespace', () => {
    const text = '<NAME> produces [SPOILER: Blue Sky meth] (#wiki/Blue_Sky)'

    expect(up.toAst(text)).to.be.eql(
      insideDocumentAndParagraph([
        new PlainTextNode('<NAME> produces '),
        new SpoilerNode([
          new LinkNode([
            new PlainTextNode('Blue Sky meth')
          ], 'https://example.com/page#wiki/Blue_Sky')
        ])
      ])
    )
{'fraction_non_alphanumeric': 0.1533109601375133, 'fraction_numerical': 0.0005729720880739953, 'mean_word_length': 2.699061459279443, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 39, 'https://': 31, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4939564', 'n_tokens_mistral': 3918, 'n_tokens_neox': 3744, 'n_words': 937}