source: imaps-frontend/node_modules/jsx-ast-utils/__tests__/src/propName-test.js@ d565449

main
Last change on this file since d565449 was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago

Update repo after prototype presentation

  • Property mode set to 100644
File size: 1.1 KB
Line 
1/* eslint-env mocha */
2import assert from 'assert';
3import { extractProp, setParserName } from '../helper';
4import propName from '../../src/propName';
5
6describe('propName', () => {
7 beforeEach(() => {
8 setParserName('babel');
9 });
10 it('should export a function', () => {
11 const expected = 'function';
12 const actual = typeof propName;
13
14 assert.equal(actual, expected);
15 });
16
17 it('should throw an error if the argument is missing', () => {
18 assert.throws(() => { propName(); }, Error);
19 });
20
21 it('should throw an error if the argument not a JSX node', () => {
22 assert.throws(() => { propName({ a: 'foo' }); }, Error);
23 });
24
25 it('should return correct name for normal prop', () => {
26 const prop = extractProp('<div foo="bar" />');
27
28 const expected = 'foo';
29 const actual = propName(prop);
30
31 assert.equal(actual, expected);
32 });
33
34 it('should return correct name for namespaced prop', () => {
35 const prop = extractProp('<div foo:bar="baz" />', 'foo:bar');
36
37 const expected = 'foo:bar';
38 const actual = propName(prop);
39
40 assert.equal(actual, expected);
41 });
42});
Note: See TracBrowser for help on using the repository browser.