Sha256: d4b6d37da1eddec49501ccbf075f655fef240dcc656079121baf49b3349cdf42

Contents?: true

Size: 1.26 KB

Versions: 4

Compression:

Stored size: 1.26 KB

Contents

require File.expand_path('../../spec_helper', File.dirname(__FILE__))

describe Tr8n::Tokens::DecorationToken do
  describe 'identifying tokens' do

    context 'incorrect tokens' do
      it 'should not be registered' do
      	[
					'Hello {bold}',
					'Hello [bold}',
					'Hello [bold]',
					'Hello [[bold]',
					'Hello [[bold]]',
					'Hello [[bold]]',
					'Hello [bold:]',
					'You have [bold {count}] messages',
      	].each do |label|
        	Tr8n::Tokens::DecorationToken.parse(label).should be_empty
        end
      end
    end

    context 'correct tokens' do
      it 'should be registered' do
      	[
					'Hello [bold: Mike]',
					'Hello [link: test]',
					'Hello [a: test]',
					'Hello [1: test]',
					'You have [bold: {count}] messages',
					'You have [bold: {count|| message}]',
				  '[link: {count} {_messages}]',
					'[link: {count||message}]',
					'[link: {count||person, people}]',
					'[link: {user.name}]'
      	].each do |label|
        	Tr8n::Tokens::DecorationToken.parse(label).count.should eq(1)
        end

      	[
					'You have [link1: {msg_count|| message}] and [link2: {alert_count|| alert}]',
      	].each do |label|
        	Tr8n::Tokens::DecorationToken.parse(label).count.should eq(2)
        end
      end
    end

  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
tr8n-3.2.3 spec/lib/tokens/decoration_token_spec.rb
tr8n-3.2.2 spec/lib/tokens/decoration_token_spec.rb
tr8n-3.2.1 spec/lib/tokens/decoration_token_spec.rb
tr8n-3.2.0 spec/lib/tokens/decoration_token_spec.rb