1. All tests have been converted into regular command-line mocha tests (instead of running in the browser), and the deployment script has been changed to automatically fail any `--new` deployment which doesn't pass. 2. Several small class (e.g., `Logger`) have been moved into a common module, `crafting-guide-common` so that they may be shared between the client and server.
49 lines
1.8 KiB
CoffeeScript
49 lines
1.8 KiB
CoffeeScript
###
|
|
Crafting Guide - command_parser_version_base.test.coffee
|
|
|
|
Copyright (c) 2015 by Redwood Labs
|
|
All rights reserved.
|
|
###
|
|
|
|
CommandParserVersionBase = require '../../src/coffee/models/parser_versions/command_parser_version_base'
|
|
|
|
########################################################################################################################
|
|
|
|
parser = null
|
|
|
|
########################################################################################################################
|
|
|
|
describe 'command_parser_version_base.coffee', ->
|
|
|
|
beforeEach -> parser = new CommandParserVersionBase model:{}
|
|
|
|
describe '_parseHereDoc', ->
|
|
|
|
it 'returns null for non-heredoc lines', ->
|
|
result = parser._parseHereDoc 'foobar: baz'
|
|
expect(result[1]).to.be.null
|
|
|
|
it 'identifies the right text for a real heredoc', ->
|
|
parser._lines = ['command: <<-END', 'alpha', 'bravo', 'charlie', 'END', 'command1: arg2']
|
|
parser._lineNumber = 1
|
|
|
|
result = parser._parseHereDoc parser._lines[0]
|
|
result[0].should.equal 'command: '
|
|
result[1].should.equal 'alpha\nbravo\ncharlie'
|
|
|
|
it 'identifies an empty heredoc', ->
|
|
parser._lines = ['command: <<-END', 'END']
|
|
parser._lineNumber = 1
|
|
|
|
result = parser._parseHereDoc parser._lines[0]
|
|
result[0].should.equal 'command: '
|
|
expect(result[1]).to.be.null
|
|
|
|
it 'trims smallest leading whitespace', ->
|
|
parser._lines = ['command: <<-END', ' alpha', ' bravo', '', ' charlie', 'END', 'command1: arg2']
|
|
parser._lineNumber = 1
|
|
|
|
result = parser._parseHereDoc parser._lines[0]
|
|
result[0].should.equal 'command: '
|
|
result[1].should.equal 'alpha\n bravo\n\ncharlie'
|