-
-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathparse.name.js
42 lines (37 loc) · 908 Bytes
/
parse.name.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
'use strict';
require('mocha');
const assert = require('assert');
const doctrine = require('doctrine');
const parseName = require('../lib/parse/name');
describe('parse name', () => {
it('should parse a name passed as a string', () => {
assert.deepEqual(parseName('foo'), {
type: 'NameExpression',
name: 'foo'
});
});
it('should parse a name passed as an object', () => {
assert.deepEqual(parseName({
type: 'NameExpression',
name: 'foo'
}), {
type: 'NameExpression',
name: 'foo'
});
});
it('should set OptionalType', () => {
assert.deepEqual(parseName('[foo]'), {
type: 'OptionalType',
expression: {
type: 'NameExpression',
name: 'foo'
}
});
});
it('should strip backticks', () => {
assert.deepEqual(parseName('`foo`'), {
type: 'NameExpression',
name: 'foo'
});
});
});