<commit_before>/* global describe it */

const chai = require('chai')
const chaiAsPromised = require('chai-as-promised')
chai.use(chaiAsPromised)
const expect = chai.expect

const remark = require('remark')
const remarkLint = require('remark-lint')
const dedent = require('dedent')

const duplicate = require('../packages/duplicate')

// Utils:

const lint = (md, options) => {
  return remark()
    .use(remarkLint)
    .use(duplicate, options)
    .process(md)
}

// Test cases:

describe('No links situation', () => {
  it(`Expect no warnings`, (done) => {
    const result = lint(dedent`
      Hello world!
      There is no problem there, because there're no links
    `)

    expect(result).to.eventually.have
      .property('messages').lengthOf(0)
      .notify(done)
  })
})

describe('Testing plugin with duplicated links', () => {
  const markdown = dedent`
    [First duplicated link](https://github.com/wemake-services/remark-lint-are-links-valid)
    [Second duplicted link](https://github.com/wemake-services/remark-lint-are-links-valid)
  `

  it('Expect warnings with default settings', () => {
    const result = lint(markdown)

    return expect(result).to.eventually.have
      .property('messages').lengthOf(1)
  })

  it('Expect no warnings with `allowDuplicates` setting', () => {
    const result = lint(markdown, {allowDuplicates: true})

    return expect(result).to.eventually.have
      .property('messages').lengthOf(0)
  })

  // TODO: check hash links
})<commit_msg>Adds extra test for hash links<commit_after>/* global describe it */

const chai = require('chai')
const chaiAsPromised = require('chai-as-promised')
chai.use(chaiAsPromised)
const expect = chai.expect

const remark = require('remark')
const remarkLint = require('remark-lint')
const dedent = require('dedent')

const duplicate = require('../packages/duplicate')

// Utils:

const lint = (md, options) => {
  return remark()
    .use(remarkLint)
    .use(duplicate, options)
    .process(md)
}

// Test cases:

describe('No links situation', () => {
  it(`Expect no warnings`, (done) => {
    const result = lint(dedent`
      Hello world!
      There is no problem there, because there're no links
    `)

    expect(result).to.eventually.have
      .property('messages').lengthOf(0)
      .notify(done)
  })
})

describe('Testing plugin with duplicated links', () => {
  const markdown = dedent`
    [First duplicated link](https://github.com/wemake-services/remark-lint-are-links-valid)
    [Second duplicted link](https://github.com/wemake-services/remark-lint-are-links-valid)
  `

  it('Expect warnings with default settings', () => {
    const result = lint(markdown)

    return expect(result).to.eventually.have
      .property('messages').lengthOf(1)
  })

  it('Expect no warnings with `allowDuplicates` setting', () => {
    const result = lint(markdown, {allowDuplicates: true})

    return expect(result).to.eventually.have
      .property('messages').lengthOf(0)
  })
})


describe('Hash links situation', () => {
  it(`Expect no warnings`, (done) => {
    const result = lint(dedent`
      # Test
      [Link](#test)
    `)

    expect(result).to.eventually.have
      .property('messages').lengthOf(0)
      .notify(done)
  })
})
{'fraction_non_alphanumeric': 0.15479494295405488, 'fraction_numerical': 0.002158495220474869, 'mean_word_length': 3.5819209039548023, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 17, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3272705', 'n_tokens_mistral': 1050, 'n_tokens_neox': 1017, 'n_words': 228}