Skip to content

Commit

Permalink
chore: rename *.test.js to *.spec.js
Browse files Browse the repository at this point in the history
This commit renames all remaining *.test.js files to have the more
popular *.spec.js suffix.
  • Loading branch information
Kristofer Selbekk committed Feb 23, 2018
1 parent 15e942d commit 2e6812a
Show file tree
Hide file tree
Showing 23 changed files with 48 additions and 31 deletions.
2 changes: 1 addition & 1 deletion packages/ffe-buttons-react/.eslintrc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"overrides": [
{
"files": [ "src/*.test.js"],
"files": [ "src/*.spec.js"],
"env": {
"jest": true
}
Expand Down
2 changes: 1 addition & 1 deletion packages/ffe-buttons-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"url": "***REMOVED***"
},
"scripts": {
"build": "babel -d lib/. --ignore=*.test.js src/.",
"build": "babel -d lib/. --ignore=*.spec.js src/.",
"lint": "eslint src/.",
"test:nsp": "nsp check",
"test:watch": "jest --watch",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@ describe('ActionButton', () => {
const button = getWrapper({
'data-analytics-track': 'logMe',
});
expect(button
.dive()
.props()).toHaveProperty('data-analytics-track', 'logMe');
expect(button.dive().props()).toHaveProperty(
'data-analytics-track',
'logMe',
);
});

describe('👻 ghost modifier 👻', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,30 +28,37 @@ describe('Button', () => {
it('does not have --loading modifier', () => {
expect(button.hasClass('ffe-primary-button--loading')).toBe(false);
const label = button.find('.ffe-primary-button__label-text');
expect(label.hasClass('ffe-primary-button__label-text--loading')).toBe(false);
expect(
label.hasClass('ffe-primary-button__label-text--loading'),
).toBe(false);
});

it('has aria-hidden on spinner', () => {
expect(button
expect(
button
.find('.ffe-primary-button__label-spinner')
.prop('aria-hidden')).toBe(true);
.prop('aria-hidden'),
).toBe(true);
});
});

describe('given prop', () => {
describe('of random name', () => {
it('passes it on', () => {
const button = shallow(<Button data-analytics-track="logMe" />);
expect(button.props()).toHaveProperty('data-analytics-track', 'logMe');
expect(button.props()).toHaveProperty(
'data-analytics-track',
'logMe',
);
});
});

describe('label', () => {
it('uses that as label text', () => {
const wrapper = shallow(<Button label="Hello" />);
expect(wrapper
.find('.ffe-primary-button__label-text')
.text()).toBe('Hello');
expect(
wrapper.find('.ffe-primary-button__label-text').text(),
).toBe('Hello');
});
});

Expand All @@ -70,10 +77,14 @@ describe('Button', () => {
});

it('adds --loading modifier', () => {
expect(button.hasClass('ffe-primary-button--loading')).toBe(true);
expect(button.hasClass('ffe-primary-button--loading')).toBe(
true,
);

const label = button.find('.ffe-primary-button__label-text');
expect(label.hasClass('ffe-primary-button__label-text--loading')).toBe(true);
expect(
label.hasClass('ffe-primary-button__label-text--loading'),
).toBe(true);
});

it('sets aria-hidden=false on spinner', () => {
Expand Down Expand Up @@ -126,24 +137,26 @@ describe('Button', () => {
describe('autoFocus', () => {
it('can be autoFocused', () => {
const wrapper = shallow(<Button autoFocus={true} />);
expect(wrapper
.find('button')
.prop('autoFocus')).toBe(true);
expect(wrapper.find('button').prop('autoFocus')).toBe(true);
});
});

describe('condensed', () => {
it('has condensed class', () => {
const button = shallow(<Button condensed={true} />);
expect(button.hasClass('ffe-primary-button--condensed')).toBe(true);
expect(button.hasClass('ffe-primary-button--condensed')).toBe(
true,
);
});
});

describe('element', () => {
it('sets the rendered element', () => {
const link = shallow(<Button element="a" href="/path">
const link = shallow(
<Button element="a" href="/path">
Link
</Button>);
</Button>,
);
expect(link.is('a')).toBe(true);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ const defaultProps = {
onClick: f => f,
};

const getWrapper = props => shallow(<InlineExpandButton {...defaultProps} {...props} />);
const getWrapper = props =>
shallow(<InlineExpandButton {...defaultProps} {...props} />);

describe('<InlineExpandButton />', () => {
it('renders without exploding', () => {
Expand All @@ -24,12 +25,14 @@ describe('<InlineExpandButton />', () => {

it('renders --expanded classes if isExpanded is true', () => {
const wrapper = getWrapper({ isExpanded: true });
expect(wrapper.hasClass('ffe-inline-expand-button--expanded')).toBe(true);
expect(wrapper
expect(wrapper.hasClass('ffe-inline-expand-button--expanded')).toBe(
true,
);
expect(
wrapper
.find(ChevronIkon)
.hasClass(
'ffe-inline-expand-button__icon--expanded',
)).toBe(true);
.hasClass('ffe-inline-expand-button__icon--expanded'),
).toBe(true);
});

it('clicks call the onClick function', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ describe('ShortcutButton', () => {

it('a Chevron icon inside the button', () => {
const button = mount(<ShortcutButton />);
expect(button
.find('svg.ffe-shortcut-button__icon-chevron')
.exists()).toBe(true);
expect(
button.find('svg.ffe-shortcut-button__icon-chevron').exists(),
).toBe(true);
});
});

Expand Down
2 changes: 1 addition & 1 deletion packages/ffe-lists-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"author": "SpareBank 1",
"license": "MIT",
"scripts": {
"build": "babel -d lib/. --ignore=*.test.js src/.",
"build": "babel -d lib/. --ignore=*.spec.js src/.",
"lint": "eslint src/",
"test": "npm run test:spec && npm run test:nsp",
"test:spec": "jest",
Expand Down
2 changes: 1 addition & 1 deletion packages/ffe-searchable-dropdown-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
},
"license": "MIT",
"scripts": {
"build": "babel -d lib --ignore=*.test.js src",
"build": "babel -d lib --ignore=*.spec.js src",
"lint": "eslint src/",
"lint:fix": "eslint --fix src/",
"test": "jest && npm run test:nsp",
Expand Down

0 comments on commit 2e6812a

Please sign in to comment.