Skip to content
This repository has been archived by the owner on May 15, 2024. It is now read-only.

Commit

Permalink
Merge pull request #1 from alleyinteractive/test-cleanup
Browse files Browse the repository at this point in the history
Test cleanup
  • Loading branch information
goodguyry committed Feb 20, 2020
2 parents 9ab415f + 329b444 commit 3a5e3db
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 13 deletions.
8 changes: 8 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
language: node_js
cache: yarn
node_js:
- node
- "12"
- "10"
install:
- YARN_IGNORE_ENGINES=true yarn
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"scripts": {
"lint": "eslint .",
"test": "jest",
"test:watch": "jest --watch"
"test:watch": "jest --watchAll"
},
"devDependencies": {
"@babel/core": "^7.8.4",
Expand Down
6 changes: 3 additions & 3 deletions src/getComponentClassnames.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,19 @@ describe('Get a hashed classname from a component', () => {
},
],
])(
'Gets the `%s` classname from `%s`',
'Gets the `%s` component',
(componentName, expected) => {
expect(getComponentClassnames(componentName)).toEqual(expected);
}
);
});

describe('Fail to find a nonexistent classname', () => {
describe('Fail to find a nonexistent component', () => {
test.each([
['mock-three'],
['foo-bar'],
])(
'The `%s` classname does not exist in `%s`',
'Ignores non-existent component `%s`',
(componentName) => {
expect(getComponentClassnames(componentName)).toMatchObject({});
}
Expand Down
4 changes: 2 additions & 2 deletions src/getComponentSelectors.spec.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable max-len */
import getComponentSelectors from './getComponentSelectors';

describe('Get the formatted classnames for a component', () => {
describe('Get the class selectors for a component', () => {
test.each([
['mock-one', {
alignleft: '.mock-one__alignleft___1cXIA',
Expand All @@ -15,7 +15,7 @@ describe('Get the formatted classnames for a component', () => {
sharedName: '.mock-two__shared-name___Kf9x0',
}],
])(
'Gets formatted classnames for %s',
'Gets class selectors from `%s`',
(componentName, expected) => {
expect(getComponentSelectors(componentName)).toEqual(expected);
}
Expand Down
6 changes: 3 additions & 3 deletions src/getElementFromComponent.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ const elements = {
},
};

describe('Test getting an element from a component', () => {
test('Getting elements from the available components', () => {
describe('Test getting elements from a component', () => {
test('Get an element from a component', () => {
const mockOneAlignLeft = getElementFromComponent('alignleft', 'mock-one');
expect(mockOneAlignLeft).toEqual(elements.mockOne.alignleft);
expect(mockOneAlignLeft).not.toEqual(elements.mockTwo.alignleft);
Expand All @@ -30,7 +30,7 @@ describe('Test getting an element from a component', () => {
expect(firstShared).toEqual(elements.mockTwo.sharedFirst);
});

test('Getting all elements from a component', () => {
test('Get all elements from a component', () => {
const allShared = getElementFromComponent('shared-name', 'mock-two', true);
expect(allShared).toEqual(elements.mockTwo.shared);
expect(allShared).toBeInstanceOf(NodeList);
Expand Down
4 changes: 2 additions & 2 deletions src/getSelectorFromComponent.spec.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
/* eslint-disable max-len */
import getSelectorFromComponent from './getSelectorFromComponent';

describe('Get a hashed classname from a component', () => {
describe('Get a hashed class selector from a component', () => {
test.each([
['alignleft', 'mock-one', '.mock-one__alignleft___1cXIA'],
['alignleft', 'mock-two', '.mock-two__alignleft___Lww3s'],
['title', 'mock-one', '.mock-one__title___2kGA7 _typography__header-main___2IME8'],
['shared-name', 'mock-two', '.mock-two__shared-name___Kf9x0'],
])(
'Gets the `%s` classname from `%s`',
'Gets the `%s` selector from `%s`',
(className, componentName, expected) => {
expect(getSelectorFromComponent(className, componentName)).toEqual(expected);
}
Expand Down
4 changes: 2 additions & 2 deletions src/util/kebabToCamelCase.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ describe('camelCase a kebab-case string', () => {
['mock-one', 'mockOne'],
['menu-item-link', 'menuItemLink'],
])(
'Gets the `%s` classname from `%s`',
'camelCases `%s` as `%s`',
(componentName, expected) => {
expect(kebabToCamelCase(componentName)).toEqual(expected);
}
Expand All @@ -18,7 +18,7 @@ describe('Ignore non-kebab-case strings', () => {
['fooBar'],
['alignleft'],
])(
'The `%s` classname does not exist in `%s`',
'Ignores `%s`',
(componentName) => {
expect(kebabToCamelCase(componentName)).toEqual(componentName);
}
Expand Down

0 comments on commit 3a5e3db

Please sign in to comment.