@yozora/jest-for-tokenizer
TypeScript icon, indicating that this package has built-in type declarations

2.3.1 • Public • Published

@yozora/jest-for-tokenizer


Jest util for testing yozora tokenizers.

Install

  • npm

    npm install --save-dev @yozora/jest-for-tokenizer
  • yarn

    yarn add --dev @yozora/jest-for-tokenizer

Usage

  • Test with @yozora/parser

    import { createTokenizerTester } from '@yozora/jest-for-tokenizer'
    import YozoraParser from '@yozora/parser'
    import CustomTokenizer from '../src'
    
    const parser = new YozoraParser({
      defaultParseOptions: {
        shouldReservePosition: true
      }
    })
      .useTokenizer(new CustomTokenizer())
    
    // Run official test cases
    createTokenizerTester(parser)
      .scan([
        'gfm/**/*.json',
        // The following cases are conflict when enabled GFM autolink (extension)
        // @see https://github.github.com/gfm/#autolinks-extension-
        '!gfm/**/#616.json',
        '!gfm/**/#619.json',
        '!gfm/**/#620.json',
      ])
      .scan('custom')
      .runTest()
    
    // Run custom test cases
    createTokenizerTester(parser)
      .scan('fixtures', __dirname)
      .runTest()
  • Test with @yozora/parser-gfm

    import { createTokenizerTester } from '@yozora/jest-for-tokenizer'
    import GfmParser from '@yozora/parser-gfm'
    import CustomTokenizer from '../src'
    
    const parser = new GfmParser({
      defaultParseOptions: {
        shouldReservePosition: true
      }
    })
      .useTokenizer(new CustomTokenizer())
    
    // Run official test cases
    createTokenizerTester(parser)
      .scan([
        'gfm/**/*.json',
        // The following cases only works when GFM extensions enabled.
        // @see https://github.github.com/gfm/#tables-extension-
        // @see https://github.github.com/gfm/#task-list-items-extension-
        // @see https://github.github.com/gfm/#strikethrough-extension-
        // @see https://github.github.com/gfm/#autolinks-extension-
        // @see https://github.github.com/gfm/#disallowed-raw-html-extension-
        '!gfm/autolink-extension/**/*',
        '!gfm/delete/**/*',
        '!gfm/list-item/task list items\\(extension\\)/**/*',
        '!gfm/table/**/*',
      ])
      .runTest()
    
    // Run custom test cases
    createTokenizerTester(parser)
      .scan('fixtures', __dirname)
      .runTest()
  • Test with @yozora/parser-gfm-ex

    import { createTokenizerTester } from '@yozora/jest-for-tokenizer'
    import GfmExParser from '@yozora/parser-gfm-ex'
    import CustomTokenizer from '../src'
    
    const parser = new GfmExParser({
      defaultParseOptions: {
        shouldReservePosition: true
      }
    })
      .useTokenizer(new CustomTokenizer())
    
    // Run official test cases
    createTokenizerTester(parser)
      .scan([
        'gfm/**/*.json',
        // The following cases are conflict when enabled GFM autolink (extension)
        // @see https://github.github.com/gfm/#example-616
        '!gfm/**/#616.json',
        '!gfm/**/#619.json',
        '!gfm/**/#620.json',
      ])
      .runTest()
    
    // Run custom test cases
    createTokenizerTester(parser)
      .scan('fixtures', __dirname)
      .runTest()

Related

Readme

Keywords

none

Package Sidebar

Install

npm i @yozora/jest-for-tokenizer

Weekly Downloads

1

Version

2.3.1

License

MIT

Unpacked Size

1.99 MB

Total Files

733

Last publish

Collaborators

  • lemonclown