Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Commit

Permalink
Merge #4313
Browse files Browse the repository at this point in the history
  • Loading branch information
jacogr committed Jan 26, 2017
2 parents eb96a6b + 7558527 commit 9c2ef43
Show file tree
Hide file tree
Showing 7 changed files with 116 additions and 18 deletions.
8 changes: 4 additions & 4 deletions js/src/ui/Form/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,26 @@
import AddressSelect from './AddressSelect';
import DappUrlInput from './DappUrlInput';
import FormWrap from './FormWrap';
import TypedInput from './TypedInput';
import Input from './Input';
import InputAddress from './InputAddress';
import InputAddressSelect from './InputAddressSelect';
import InputChip from './InputChip';
import InputInline from './InputInline';
import Select from './Select';
import RadioButtons from './RadioButtons';
import Select from './Select';
import TypedInput from './TypedInput';

export default from './form';
export {
AddressSelect,
DappUrlInput,
FormWrap,
TypedInput,
Input,
InputAddress,
InputAddressSelect,
InputChip,
InputInline,
RadioButtons,
Select,
RadioButtons
TypedInput
};
2 changes: 1 addition & 1 deletion js/src/ui/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import DappIcon from './DappIcon';
import Editor from './Editor';
import Errors from './Errors';
import Features, { FEATURES, FeaturesStore } from './Features';
import Form, { AddressSelect, DappUrlInput, FormWrap, TypedInput, Input, InputAddress, InputAddressSelect, InputChip, InputInline, RadioButtons, Select } from './Form';
import Form, { AddressSelect, DappUrlInput, FormWrap, Input, InputAddress, InputAddressSelect, InputChip, InputInline, RadioButtons, Select, TypedInput } from './Form';
import GasPriceEditor from './GasPriceEditor';
import GasPriceSelector from './GasPriceSelector';
import Icons from './Icons';
Expand Down
48 changes: 48 additions & 0 deletions js/src/views/Web/AddressBar/addressBar.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// Copyright 2015-2017 Parity Technologies (UK) Ltd.
// This file is part of Parity.

// Parity is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.

// Parity is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with Parity. If not, see <http://www.gnu.org/licenses/>.

import { shallow } from 'enzyme';
import React from 'react';

import AddressBar from './';

let component;
let store;

function createStore () {
store = {
nextUrl: 'https://parity.io'
};

return store;
}

function render (props = {}) {
component = shallow(
<AddressBar
className='testClass'
store={ createStore() }
/>
);

return component;
}

describe('AddressBar', () => {
it('renders defaults', () => {
expect(render()).to.be.ok;
});
});
1 change: 0 additions & 1 deletion js/src/views/Web/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ export default class Store {
return this._api.parity
.listRecentDapps()
.then((apps) => {
console.log(apps);
this.setHistory(apps);
})
.catch((error) => {
Expand Down
11 changes: 1 addition & 10 deletions js/src/views/Web/store.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,6 @@ function create () {
describe('views/Web/Store', () => {
beforeEach(() => {
create();
sinon.spy(store.historyStore, 'add');
});

afterEach(() => {
store.historyStore.add.restore();
});

describe('@action', () => {
Expand All @@ -76,16 +71,12 @@ describe('views/Web/Store', () => {
it('sets the url', () => {
expect(store.currentUrl).to.equal(TEST_URL1);
});

it('saves the url in the history', () => {
expect(store.historyStore.add).to.have.been.calledWith(TEST_URL1);
});
});

describe('setHistory', () => {
it('sets the history', () => {
store.setHistory(TEST_HISTORY);
expect(this.history.peek()).to.deep.equal(TEST_HISTORY);
expect(store.history.peek()).to.deep.equal(TEST_HISTORY);
});
});

Expand Down
8 changes: 6 additions & 2 deletions js/src/views/Web/web.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import { observer } from 'mobx-react';
import React, { Component, PropTypes } from 'react';
import { FormattedMessage } from 'react-intl';

import AddressBar from './AddressBar';
import Store from './store';
Expand All @@ -35,8 +36,8 @@ export default class Web extends Component {
store = Store.get(this.context.api);

componentDidMount () {
this.store.generateToken();
this.store.gotoUrl(this.props.params.url);
return this.store.generateToken();
}

componentWillReceiveProps (props) {
Expand All @@ -50,7 +51,10 @@ export default class Web extends Component {
return (
<div className={ styles.wrapper }>
<h1 className={ styles.loading }>
Requesting access token...
<FormattedMessage
id='web.requestToken'
defaultMessage='Requesting access token...'
/>
</h1>
</div>
);
Expand Down
56 changes: 56 additions & 0 deletions js/src/views/Web/web.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// Copyright 2015-2017 Parity Technologies (UK) Ltd.
// This file is part of Parity.

// Parity is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.

// Parity is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with Parity. If not, see <http://www.gnu.org/licenses/>.

import { shallow } from 'enzyme';
import React from 'react';

import Web from './';

const TEST_URL = 'https://mkr.market';

let api;
let component;

function createApi () {
api = {};

return api;
}

function render (url = TEST_URL) {
component = shallow(
<Web params={ { url } } />,
{
context: { api: createApi() }
}
);

return component;
}

describe('Web', () => {
beforeEach(() => {
render();
});

it('renders defaults', () => {
expect(component).to.be.ok;
});

it('renders loading with no token', () => {
expect(component.find('FormattedMessage').props().id).to.equal('web.requestToken');
});
});

0 comments on commit 9c2ef43

Please sign in to comment.