Skip to content

Commit

Permalink
Merge pull request #122 from miha-plesko/react-setup-tests
Browse files Browse the repository at this point in the history
Setup JavaScript tests for Nuage provider
  • Loading branch information
agrare committed Aug 7, 2018
2 parents 87931f0 + 36131df commit 48b1522
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 2 deletions.
16 changes: 14 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,29 @@ rvm:
- 2.4.4
- 2.3.6
sudo: required
cache: bundler
cache:
bundler: true
yarn: true
env:
global:
- RUBY_GC_HEAP_GROWTH_MAX_SLOTS=300000
- RUBY_GC_HEAP_INIT_SLOTS=600000
- RUBY_GC_HEAP_GROWTH_FACTOR=1.25
- BUNDLE_WITH=qpid_proton
matrix:
- TEST_SUITE=spec
- TEST_SUITE=yarn:test
matrix:
exclude:
- rvm: 2.3.6
env: TEST_SUITE=yarn:test
addons:
postgresql: '9.4'
before_install: bin/qpid_install.sh
install: bin/setup
install:
- bin/setup
- "bundle exec rake yarn:install"
script: bundle exec rake $TEST_SUITE
after_script: bundle exec codeclimate-test-reporter
notifications:
webhooks:
Expand Down
14 changes: 14 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,18 @@ require 'bundler/gem_tasks'

FileList['lib/tasks_private/**/*.rake'].each { |r| load r }

namespace :yarn do
desc "install yarn dependencies"
task :install do
system('yarn install')
exit $CHILD_STATUS.exitstatus
end

desc "run jest tests"
task :test do
system('yarn test')
exit $CHILD_STATUS.exitstatus
end
end

task :default => :spec
11 changes: 11 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,22 @@
"babel-preset-es2015": "^6.24.1",
"babel-preset-react": "^6.24.1",
"babel-preset-stage-1": "^6.24.1",
"enzyme": "^3.3.0",
"enzyme-adapter-react-16": "^1.1.1",
"enzyme-to-json": "^3.3.4",
"jest": "^23.4.2"
},
"engines": {
"node": ">= 6.9.1",
"npm": ">= 3.10.3",
"yarn": ">= 0.20.1"
},
"scripts": {
"test": "jest"
},
"jest": {
"testURL": "http://localhost",
"setupTestFrameworkScriptFile": "<rootDir>/spec/javascript/setup.js",
"testPathDirs": ["<rootDir>/spec/javascript"]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`<Spinner/> renders <Spinner> component 1`] = `
<div
className="spinner spinner-md"
/>
`;
11 changes: 11 additions & 0 deletions spec/javascript/components/components.test.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import React from 'react';
import { shallow } from 'enzyme';
import toJson from 'enzyme-to-json';

import { Spinner } from 'patternfly-react';

describe('<Spinner/>', () => {
it('renders <Spinner> component', () => {
expect(toJson(shallow(<Spinner loading />))).toMatchSnapshot();
});
});
4 changes: 4 additions & 0 deletions spec/javascript/setup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import Enzyme from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';

Enzyme.configure({ adapter: new Adapter() });
3 changes: 3 additions & 0 deletions spec/javascript/utils/api.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
test('1 + 2 = 3', () => {
expect(1 + 2).toBe(3);
});

0 comments on commit 48b1522

Please sign in to comment.