/* eslint no-unused-expressions: "off" */
/* eslint-env mocha */

'use strict';

const chai = require('chai');
const expect = chai.expect;
const Lexer = require('../src/lexer/lexer.js');

describe('Lexer', () => {
  it('can tokenize some text', () => {
    const lexer = new Lexer();
    lexer.setInput('This is some text');

    expect(lexer.lex()).to.equal('Text');
  });

  it('can tokenize an option', () => {
    const lexer = new Lexer();
    lexer.setInput('[[option]]');

    expect(lexer.lex()).to.equal('OptionStart');
    expect(lexer.lex()).to.equal('Text');
    expect(lexer.lex()).to.equal('OptionEnd');
  });

  it('can tokenize a named option', () => {
    const lexer = new Lexer();
    lexer.setInput('[[option|dest]]');

    expect(lexer.lex()).to.equal('OptionStart');
    expect(lexer.lex()).to.equal('Text');
    expect(lexer.lex()).to.equal('OptionDelimit');
    expect(lexer.lex()).to.equal('Identifier');
    expect(lexer.lex()).to.equal('OptionEnd');
  });

  it('can tokenize some text followed by an option', () => {
    const lexer = new Lexer();
    lexer.setInput('text [[option]]');

    expect(lexer.lex()).to.equal('Text');
    expect(lexer.lex()).to.equal('OptionStart');
    expect(lexer.lex()).to.equal('Text');
    expect(lexer.lex()).to.equal('OptionEnd');
  });

  it('can tokenize an option followed by some text', () => {
    const lexer = new Lexer();
    lexer.setInput('[[option]] text');

    expect(lexer.lex()).to.equal('OptionStart');
    expect(lexer.lex()).to.equal('Text');
    expect(lexer.lex()).to.equal('OptionEnd');
    expect(lexer.lex()).to.equal('Text');
  });

  it('can tokenize a named option followed by some text', () => {
    const lexer = new Lexer();
    lexer.setInput('[[option|blah]] text');

    expect(lexer.lex()).to.equal('OptionStart');
    expect(lexer.lex()).to.equal('Text');
    expect(lexer.lex()).to.equal('OptionDelimit');
    expect(lexer.lex()).to.equal('Identifier');
    expect(lexer.lex()).to.equal('OptionEnd');
    expect(lexer.lex()).to.equal('Text');
  });

  it('can tokenize a command', () => {
    const lexer = new Lexer();
    lexer.setInput('<<option>>');

    expect(lexer.lex()).to.equal('BeginCommand');
    expect(lexer.lex()).to.equal('Identifier');
    expect(lexer.lex()).to.equal('EndCommand');
  });
});

@@ -108,36 +108,8 @@
 ');%0A
-const expect = chai.expect;%0A
 cons
@@ -153,16 +153,45 @@
 .js');%0A%0A
+const expect = chai.expect;%0A%0A
 describe
@@ -604,32 +604,80 @@
 l('OptionEnd');%0A
+    expect(lexer.lex()).to.equal('EndOfInput');%0A
   %7D);%0A%0A  it('can
@@ -1011,32 +1011,80 @@
 l('OptionEnd');%0A
+    expect(lexer.lex()).to.equal('EndOfInput');%0A
   %7D);%0A%0A  it('can
@@ -1382,24 +1382,72 @@
 ptionEnd');%0A
+    expect(lexer.lex()).to.equal('EndOfInput');%0A
   %7D);%0A%0A  it(
@@ -1745,32 +1745,80 @@
 .equal('Text');%0A
+    expect(lexer.lex()).to.equal('EndOfInput');%0A
   %7D);%0A%0A  it('can
@@ -2221,32 +2221,80 @@
 .equal('Text');%0A
+    expect(lexer.lex()).to.equal('EndOfInput');%0A
   %7D);%0A%0A  it('can
@@ -2479,32 +2479,32 @@
 ('Identifier');%0A
-
     expect(lexer
@@ -2531,22 +2531,819 @@
 dCommand');%0A
+    expect(lexer.lex()).to.equal('EndOfInput');%0A  %7D);%0A%0A  it('can tokenize shortcut options', () =%3E %7B%0A    const lexer = new Lexer();%0A    lexer.setInput('text%5Cn-%3E shortcut1%5Cn%5CtText1%5Cn-%3E shorcut2%5Cn%5CtText2%5Cnmore text');%0A%0A    expect(lexer.lex()).to.equal('Text');%0A    expect(lexer.lex()).to.equal('ShortcutOption');%0A    expect(lexer.lex()).to.equal('Text');%0A    expect(lexer.lex()).to.equal('Indent');%0A    expect(lexer.lex()).to.equal('Text');%0A    expect(lexer.lex()).to.equal('Dedent');%0A    expect(lexer.lex()).to.equal('ShortcutOption');%0A    expect(lexer.lex()).to.equal('Text');%0A    expect(lexer.lex()).to.equal('Indent');%0A    expect(lexer.lex()).to.equal('Text');%0A    expect(lexer.lex()).to.equal('Dedent');%0A    expect(lexer.lex()).to.equal('Text');%0A    expect(lexer.lex()).to.equal('EndOfInput');%0A
   %7D);%0A%7D);%0A

Add lexer test for shortcut options