Last active
August 29, 2015 13:59
-
-
Save stephenprater/10659056 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class QueryNode.Literal | |
constructor: (@arg)-> | |
toJSON:()-> | |
switch typeof(@arg) | |
when 'string' then "\"#{@arg}\"" | |
when 'number', 'boolean' then @arg | |
when 'object' | |
if @arg == null | |
@arg | |
else | |
throw new Error('Literal cannot accept an object') | |
#test | |
describe 'QueryNode.Literal', -> | |
it 'throws an error for objects', -> | |
j = new QueryNode.Literal({'hey':'you'}) | |
expect(j.toJSON).to.throwError() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment