Skip to content

Commit e3ff84d

Browse files
nfourbrendo
authored andcommitted
Fix lint for tests, use join on paths (temando#108)
1 parent 1b6ea5d commit e3ff84d

14 files changed

+209
-205
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
],
1818
"scripts": {
1919
"start": "webpack-dev-server",
20-
"lint": "eslint src",
20+
"lint": "eslint src test",
2121
"test": "jest",
2222
"test:coverage": "jest --coverage",
2323
"build:prod": "rm -rf dist/* && NODE_ENV=prod webpack -p"

test/components/Description.test.js

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,32 @@
1-
import React from 'react';
2-
import Description from './../../src/components/Description/Description';
3-
import renderer from 'react-test-renderer';
1+
import React from 'react'
2+
import Description from './../../src/components/Description/Description'
3+
import renderer from 'react-test-renderer'
44

55
describe('<Description />', () => {
66
it('renders text with no commonmark as html', () => {
7-
const text = 'This method has zero markdown.';
7+
const text = 'This method has zero markdown.'
88
const tree = renderer.create(
99
<Description description={text} />
10-
);
10+
)
1111

12-
expect(tree).toMatchSnapshot();
13-
});
12+
expect(tree).toMatchSnapshot()
13+
})
1414

1515
it('renders commonmark text as html', () => {
16-
const text = 'This method has some `var i = 0` _markdown_, including a [link](http://www.google.com).';
16+
const text = 'This method has some `var i = 0` _markdown_, including a [link](http://www.google.com).'
1717
const tree = renderer.create(
1818
<Description description={text} />
19-
);
19+
)
2020

21-
expect(tree).toMatchSnapshot();
22-
});
21+
expect(tree).toMatchSnapshot()
22+
})
2323

2424
it('renders text inline if asked', () => {
25-
const text = 'This method has zero markdown.';
25+
const text = 'This method has zero markdown.'
2626
const tree = renderer.create(
2727
<Description isInline description={text} />
28-
).toJSON();
28+
).toJSON()
2929

30-
expect(tree).toMatchSnapshot();
31-
});
32-
});
30+
expect(tree).toMatchSnapshot()
31+
})
32+
})

test/components/Property.test.js

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
import React from 'react';
2-
import Property from './../../src/components/Property/Property';
3-
import renderer from 'react-test-renderer';
4-
import ReactShallowRenderer from 'react-test-renderer/shallow';
1+
import React from 'react'
2+
import Property from './../../src/components/Property/Property'
3+
import renderer from 'react-test-renderer'
4+
import ReactShallowRenderer from 'react-test-renderer/shallow'
55

66
describe('<Property />', () => {
77
it('can render a basic property', () => {
88
const tree = renderer.create(
99
<Property name={'type'} type={['string']} isRequired isLast />
10-
);
10+
)
1111

12-
expect(tree).toMatchSnapshot();
13-
});
12+
expect(tree).toMatchSnapshot()
13+
})
1414

1515
it('can render a property with enum', () => {
1616
const tree = renderer.create(
@@ -19,10 +19,10 @@ describe('<Property />', () => {
1919
type={['string']}
2020
enumValues={['box', 'carton']}
2121
isRequired />
22-
);
22+
)
2323

24-
expect(tree).toMatchSnapshot();
25-
});
24+
expect(tree).toMatchSnapshot()
25+
})
2626

2727
it('can render a property with a subtype', () => {
2828
const tree = renderer.create(
@@ -31,47 +31,47 @@ describe('<Property />', () => {
3131
type={['array']}
3232
subtype={'object'}
3333
isRequired={false} />
34-
);
34+
)
3535

36-
expect(tree).toMatchSnapshot();
37-
});
36+
expect(tree).toMatchSnapshot()
37+
})
3838

3939
it('can render a property with description', () => {
40-
const shallow = new ReactShallowRenderer();
40+
const shallow = new ReactShallowRenderer()
4141
const tree = shallow.render(
4242
<Property
4343
name={'type'}
4444
type={['string']}
4545
description={'This is _markdown_ text'}
4646
isRequired />
47-
);
47+
)
4848

49-
expect(tree).toMatchSnapshot();
50-
});
49+
expect(tree).toMatchSnapshot()
50+
})
5151

5252
it('can render a property with numerical constraints', () => {
53-
const shallow = new ReactShallowRenderer();
53+
const shallow = new ReactShallowRenderer()
5454
const tree = shallow.render(
5555
<Property
5656
name={'type'}
5757
type={['number']}
5858
constraints={{multipleOf: 2}}
5959
isRequired />
60-
);
60+
)
6161

62-
expect(tree).toMatchSnapshot();
63-
});
62+
expect(tree).toMatchSnapshot()
63+
})
6464

6565
it('can render a property with multiple types', () => {
6666
const tree = renderer.create(
6767
<Property
6868
name={'value'}
6969
type={['string', 'number']}
7070
isRequired={false} />
71-
);
71+
)
7272

73-
expect(tree).toMatchSnapshot();
74-
});
73+
expect(tree).toMatchSnapshot()
74+
})
7575

7676
it('can render a property with a format', () => {
7777
const tree = renderer.create(
@@ -80,8 +80,8 @@ describe('<Property />', () => {
8080
constraints={{format: 'email'}}
8181
type={['string']}
8282
isRequired={false} />
83-
);
83+
)
8484

85-
expect(tree).toMatchSnapshot();
86-
});
87-
});
85+
expect(tree).toMatchSnapshot()
86+
})
87+
})
Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,45 @@
1-
import React from 'react';
2-
import PropertyConstraints from './../../src/components/PropertyConstraints/PropertyConstraints';
3-
import renderer from 'react-test-renderer';
1+
import React from 'react'
2+
import PropertyConstraints from './../../src/components/PropertyConstraints/PropertyConstraints'
3+
import renderer from 'react-test-renderer'
44

55
describe('<PropertyConstraints />', () => {
66
it('renders required constraint', () => {
77
let tree = renderer.create(
88
<PropertyConstraints type={['string']} isRequired />
9-
).toJSON();
9+
).toJSON()
1010

11-
expect(tree).toMatchSnapshot();
12-
});
11+
expect(tree).toMatchSnapshot()
12+
})
1313

1414
it('renders array constraints', () => {
1515
const tree = renderer.create(
1616
<PropertyConstraints type={['array']} isRequired={false} constraints={{uniqueItems: true}} />
17-
);
17+
)
1818

19-
expect(tree).toMatchSnapshot();
20-
});
19+
expect(tree).toMatchSnapshot()
20+
})
2121

2222
it('renders numeric constraints', () => {
2323
const tree = renderer.create(
2424
<PropertyConstraints type={['numeric']} isRequired={false} constraints={{minimum: 2}} />
25-
);
25+
)
2626

27-
expect(tree).toMatchSnapshot();
28-
});
27+
expect(tree).toMatchSnapshot()
28+
})
2929

3030
it('renders object constraints', () => {
3131
const tree = renderer.create(
3232
<PropertyConstraints type={['object']} isRequired={false} constraints={{minProperties: 2}} />
33-
);
33+
)
3434

35-
expect(tree).toMatchSnapshot();
36-
});
35+
expect(tree).toMatchSnapshot()
36+
})
3737

3838
it('renders string constraints', () => {
3939
const tree = renderer.create(
4040
<PropertyConstraints type={['string']} isRequired={false} constraints={{pattern: '^[a-zA-Z0-9_-]+$'}} />
41-
);
41+
)
4242

43-
expect(tree).toMatchSnapshot();
44-
});
45-
});
43+
expect(tree).toMatchSnapshot()
44+
})
45+
})

test/parser/open-api/allOfResolver.test.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import { getTestsFromFixtures } from '../../fixtureLoader'
22
import { resolveAllOf } from '../../../src/parser/open-api/allOfResolver'
3+
import { join } from 'path'
34

45
describe('resolveAllOf', () => {
5-
const dataDirectory = __dirname + '/data/allOfResolver'
6+
const dataDirectory = join(__dirname, '/data/allOfResolver')
67
const tests = getTestsFromFixtures(`${dataDirectory}/inputs`, `${dataDirectory}/outputs`)
78

89
tests.forEach(test => {
Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,50 @@
1-
import { getConstraintHints } from '../../../../src/parser/open-api/constraints/array';
1+
import { getConstraintHints } from '../../../../src/parser/open-api/constraints/array'
22

33
describe('array constraints', () => {
44
it('handles non-applicable constraints', () => {
5-
const hints = getConstraintHints({pattern: '^[a-zA-Z0-9_-]+$'});
5+
const hints = getConstraintHints({pattern: '^[a-zA-Z0-9_-]+$'})
66

7-
expect(hints).toHaveLength(0);
8-
});
7+
expect(hints).toHaveLength(0)
8+
})
99

1010
it('handles uniqueItems', () => {
11-
const hints = getConstraintHints({uniqueItems: true});
11+
const hints = getConstraintHints({uniqueItems: true})
1212

13-
expect(hints).toHaveLength(1);
14-
expect(hints).toContain('unique items');
15-
});
13+
expect(hints).toHaveLength(1)
14+
expect(hints).toContain('unique items')
15+
})
1616

1717
it('handles minItems', () => {
18-
const hints = getConstraintHints({minItems: 2});
18+
const hints = getConstraintHints({minItems: 2})
1919

20-
expect(hints).toHaveLength(1);
21-
expect(hints).toContain('at least 2 items');
22-
});
20+
expect(hints).toHaveLength(1)
21+
expect(hints).toContain('at least 2 items')
22+
})
2323

2424
it('handles maxItems', () => {
25-
const hints = getConstraintHints({maxItems: 10});
25+
const hints = getConstraintHints({maxItems: 10})
2626

27-
expect(hints).toHaveLength(1);
28-
expect(hints).toContain('at most 10 items');
29-
});
27+
expect(hints).toHaveLength(1)
28+
expect(hints).toContain('at most 10 items')
29+
})
3030

3131
it('handles minItems and maxItems', () => {
32-
const hints = getConstraintHints({minItems: 4, maxItems: 10});
32+
const hints = getConstraintHints({minItems: 4, maxItems: 10})
3333

34-
expect(hints).toHaveLength(1);
35-
expect(hints).toContain('4-10 items');
36-
});
34+
expect(hints).toHaveLength(1)
35+
expect(hints).toContain('4-10 items')
36+
})
3737

3838
it('handles minItems and maxItems when they are the same value', () => {
39-
const hints = getConstraintHints({minItems: 4, maxItems: 4});
39+
const hints = getConstraintHints({minItems: 4, maxItems: 4})
4040

41-
expect(hints).toHaveLength(1);
42-
expect(hints).toContain('4 items');
43-
});
41+
expect(hints).toHaveLength(1)
42+
expect(hints).toContain('4 items')
43+
})
4444

4545
it('handles uniqueItems, minItems and maxItems', () => {
46-
const hints = getConstraintHints({uniqueItems: true, minItems: 4, maxItems: 10});
46+
const hints = getConstraintHints({uniqueItems: true, minItems: 4, maxItems: 10})
4747

48-
expect(hints).toHaveLength(2);
49-
});
50-
});
48+
expect(hints).toHaveLength(2)
49+
})
50+
})
Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { VALIDATION_KEYWORDS, hasConstraints, getConstraints } from '../../../../src/parser/open-api/constraints/constraintsParser';
1+
import { VALIDATION_KEYWORDS, hasConstraints, getConstraints } from '../../../../src/parser/open-api/constraints/constraintsParser'
22

33
describe('VALIDATION_KEYWORDS', () => {
44
test('keywords match what is supported by Open API', () => {
@@ -17,40 +17,40 @@ describe('VALIDATION_KEYWORDS', () => {
1717
'multipleOf',
1818
'pattern',
1919
'uniqueItems'
20-
]);
21-
});
22-
});
20+
])
21+
})
22+
})
2323

2424
describe('#hasConstraints', () => {
2525
test('returns true when the property contains constraints', () => {
2626
const property = {
2727
type: 'string',
2828
pattern: '^[a-zA-Z0-9_-]+$'
29-
};
29+
}
3030

31-
expect(hasConstraints(property)).toBeTruthy();
32-
});
31+
expect(hasConstraints(property)).toBeTruthy()
32+
})
3333

3434
test('returns false when the property has no constraints', () => {
3535
const property = {
3636
type: 'string'
37-
};
37+
}
3838

39-
expect(hasConstraints(property)).toBeFalsy();
40-
});
41-
});
39+
expect(hasConstraints(property)).toBeFalsy()
40+
})
41+
})
4242

4343
describe('#getConstraints', () => {
4444
test('can create a constraints object with appropriate constraints', () => {
4545
const property = {
4646
type: 'string',
4747
pattern: '^[a-zA-Z0-9_-]+$'
48-
};
48+
}
4949

5050
const constraints = {
5151
pattern: '^[a-zA-Z0-9_-]+$'
52-
};
52+
}
5353

54-
expect(getConstraints(property)).toEqual(constraints);
55-
});
56-
});
54+
expect(getConstraints(property)).toEqual(constraints)
55+
})
56+
})

0 commit comments

Comments
 (0)