Commit ba7a3415 authored by Martin Santangelo's avatar Martin Santangelo

(chore) fix spec tests

1 merge request!325WIP: [Sprint/ModestMonkey] wire epic 37
......@@ -13,7 +13,7 @@ exports[`ForgotPassword component should renders correctly 1`] = `
style={
Array [
Object {
"color": "white",
"color": "#FFFFFF",
},
Object {
"fontSize": 14,
......
......@@ -77,7 +77,7 @@ exports[`ForgotScreen component should renders correctly 1`] = `
style={
Array [
Object {
"color": "white",
"color": "#FFFFFF",
},
Object {
"fontSize": 14,
......
......@@ -342,7 +342,7 @@ exports[`LoginForm component should renders correctly 1`] = `
style={
Array [
Object {
"color": "white",
"color": "#FFFFFF",
},
Object {
"fontWeight": "bold",
......@@ -396,7 +396,7 @@ exports[`LoginForm component should renders correctly 1`] = `
style={
Array [
Object {
"color": "white",
"color": "#FFFFFF",
},
]
}
......@@ -506,7 +506,7 @@ exports[`LoginForm component should renders correctly 1`] = `
"padding": 10,
},
Object {
"color": "white",
"color": "#FFFFFF",
},
]
}
......@@ -634,7 +634,7 @@ exports[`LoginForm component should renders correctly 1`] = `
"alignItems": "center",
"backgroundColor": "white",
"borderColor": "#777777",
"borderRadius": 15,
"borderRadius": 20,
"borderWidth": 1,
"margin": 4,
"opacity": 1,
......@@ -671,7 +671,7 @@ exports[`LoginForm component should renders correctly 1`] = `
"alignItems": "center",
"backgroundColor": "white",
"borderColor": "#4690D6",
"borderRadius": 15,
"borderRadius": 20,
"borderWidth": 1,
"margin": 4,
"opacity": 1,
......
......@@ -3,18 +3,19 @@
exports[`channel actions component should renders correctly 1`] = `
<View
style={
Object {
"alignItems": "center",
"backgroundColor": "#FFF",
"flexDirection": "row",
"height": 40,
"justifyContent": "flex-end",
"paddingLeft": 8,
"width": 40,
}
Array [
Object {
"flexDirection": "row",
"justifyContent": "flex-end",
},
Object {
"marginTop": 10,
},
]
}
>
<View
accessibilityLabel="Wire Button"
accessible={true}
isTVSelectable={true}
onResponderGrant={[Function]}
......@@ -25,12 +26,16 @@ exports[`channel actions component should renders correctly 1`] = `
onStartShouldSetResponder={[Function]}
style={
Object {
"alignContent": "center",
"alignItems": "center",
"alignSelf": "center",
"flex": 1,
"backgroundColor": "white",
"borderColor": "#4690D6",
"borderRadius": 20,
"borderWidth": 1,
"flexDirection": "row",
"justifyContent": "center",
"margin": 4,
"opacity": 1,
"padding": 4,
}
}
>
......@@ -39,10 +44,17 @@ exports[`channel actions component should renders correctly 1`] = `
style={
Array [
Object {
"color": "rgb(70, 144, 214)",
"fontSize": 40,
"color": undefined,
"fontSize": 18,
},
undefined,
Array [
Object {
"marginLeft": 5,
},
Object {
"color": "#4690D6",
},
],
Object {
"fontFamily": "Ionicons",
"fontStyle": "normal",
......@@ -54,30 +66,74 @@ exports[`channel actions component should renders correctly 1`] = `
>
</Text>
<Text
style={
Array [
Object {
"color": "#4690D6",
},
Array [
Object {
"marginLeft": 5,
},
Object {
"marginRight": 5,
},
],
]
}
>
Wire
</Text>
</View>
<Text
allowFontScaling={false}
onPress={[Function]}
<View
accessibilityLabel="More"
accessible={true}
isTVSelectable={true}
onResponderGrant={[Function]}
onResponderMove={[Function]}
onResponderRelease={[Function]}
onResponderTerminate={[Function]}
onResponderTerminationRequest={[Function]}
onStartShouldSetResponder={[Function]}
style={
Array [
Object {
"color": undefined,
"fontSize": 24,
},
Object {
"color": "#888888",
"paddingLeft": 10,
},
Object {
"fontFamily": "Ionicons",
"fontStyle": "normal",
"fontWeight": "normal",
},
Object {},
]
Object {
"alignItems": "center",
"backgroundColor": "white",
"borderColor": "#4690D6",
"borderRadius": 20,
"borderWidth": 1,
"flexDirection": "row",
"justifyContent": "center",
"margin": 4,
"opacity": 1,
"padding": 4,
}
}
>
</Text>
<Text
style={
Array [
Object {
"color": "#4690D6",
},
Array [
Object {
"marginLeft": 5,
},
Object {
"marginRight": 5,
},
],
]
}
>
More
</Text>
</View>
</View>
`;
......@@ -134,9 +134,9 @@ exports[`Channel screen component should renders correctly 1`] = `
},
"buttonscol": Object {
"alignItems": "center",
"alignSelf": "flex-end",
"alignSelf": "flex-start",
"flexDirection": "row",
"justifyContent": "flex-end",
"justifyContent": "flex-start",
},
"carouselcontainer": Object {
"flex": 1,
......@@ -187,7 +187,7 @@ exports[`Channel screen component should renders correctly 1`] = `
"name": Object {
"color": "#444",
"fontFamily": "Roboto",
"fontSize": 20,
"fontSize": 22,
"fontWeight": "700",
"letterSpacing": 0.5,
"marginRight": 8,
......@@ -224,7 +224,7 @@ exports[`Channel screen component should renders correctly 1`] = `
},
"username": Object {
"color": "#999",
"fontSize": 10,
"fontSize": 14,
},
"wrappedAvatar": Object {
"borderRadius": 55,
......
......@@ -180,74 +180,60 @@ exports[`channel header component owner should render correctly 1`] = `
someusermane
</Text>
</View>
<View>
<TouchableHighlight
accessibilityLabel="Subscribe to this channel"
onPress={[Function]}
style={
Array [
Object {
"borderColor": "#ececec",
"borderRadius": 30,
"borderWidth": 1,
"padding": 8,
},
Object {
"borderColor": "#4690D6",
},
undefined,
]
}
underlayColor="transparent"
>
<Text
style={
Object {
"color": "#4690D6",
}
}
>
SUBSCRIBE
</Text>
</TouchableHighlight>
</View>
<View>
<View
style={
Array [
Object {
"flexDirection": "row",
"justifyContent": "flex-end",
},
Object {
"marginTop": 10,
},
]
}
>
<View
accessibilityLabel="Subscribe to this channel"
accessible={true}
isTVSelectable={true}
onResponderGrant={[Function]}
onResponderMove={[Function]}
onResponderRelease={[Function]}
onResponderTerminate={[Function]}
onResponderTerminationRequest={[Function]}
onStartShouldSetResponder={[Function]}
style={
Object {
"alignItems": "center",
"backgroundColor": "#FFF",
"backgroundColor": "white",
"borderColor": "#4690D6",
"borderRadius": 20,
"borderWidth": 1,
"flexDirection": "row",
"height": 40,
"justifyContent": "flex-end",
"paddingLeft": 8,
"width": 60,
"justifyContent": "center",
"margin": 4,
"marginLeft": 0,
"opacity": 1,
"padding": 4,
}
}
>
<Text
allowFontScaling={false}
onPress={[Function]}
style={
Array [
Object {
"color": undefined,
"fontSize": 24,
},
Object {
"color": "#888888",
"paddingLeft": 10,
},
Object {
"fontFamily": "Ionicons",
"fontStyle": "normal",
"fontWeight": "normal",
"color": "#4690D6",
},
Object {},
undefined,
]
}
>
SUBSCRIBE
</Text>
</View>
</View>
......
......@@ -15,7 +15,7 @@ exports[`renders correctly 1`] = `
"alignItems": "center",
"backgroundColor": "white",
"borderColor": "#4690D6",
"borderRadius": 15,
"borderRadius": 20,
"borderWidth": 1,
"margin": 4,
"opacity": 1,
......
......@@ -51,7 +51,7 @@ exports[`Explicit overlay component renders correctly 1`] = `
style={
Array [
Object {
"color": "white",
"color": "#FFFFFF",
},
Object {
"elevation": 4,
......
......@@ -134,48 +134,6 @@ describe('wire service', () => {
return expect(WireService.send({amount: 1})).resolves.toBeUndefined();
});
it('it should send credit card wire', async(done) => {
const fakePayload = {
type: 'creditcard',
token: 10
};
api.post.mockResolvedValue({postresult: 1});
BlockchainWalletService.selectCurrent.mockResolvedValue(fakePayload);
try {
const result = await WireService.send({amount: 1, guid: 123123123});
// expect post to be called with the payload
expect(api.post).toBeCalledWith(`api/v1/wire/123123123`, {
amount: 1,
method: 'tokens',
payload: {
address: 'offchain',
method: 'creditcard',
token: 10
},
recurring: false
});
// expect to return the post result with the payload added
expect(result).toEqual({
postresult: 1,
payload: {
address: 'offchain',
method: 'creditcard',
token: 10
}
});
} catch(e) {
done.fail(e);
}
done();
});
it('it should send offchain wire', async(done) => {
const fakePayload = {
......@@ -187,12 +145,12 @@ describe('wire service', () => {
BlockchainWalletService.selectCurrent.mockResolvedValue(fakePayload);
try {
const result = await WireService.send({amount: 1, guid: 123123123});
const result = await WireService.send({amount: 1, guid: 123123123, currency: 'tokens'});
// expect post to be called with the payload
expect(api.post).toBeCalledWith(`api/v1/wire/123123123`, {
expect(api.post).toBeCalledWith(`api/v2/wire/123123123`, {
amount: 1,
method: 'tokens',
method: 'offchain',
payload: {
method: 'offchain',
address: 'offchain'
......@@ -230,12 +188,12 @@ describe('wire service', () => {
BlockchainWireService.create.mockResolvedValue('0xtxhash');
try {
const result = await WireService.send({amount: 1, guid: 123123123, owner: {eth_wallet: '0xaddress'}});
const result = await WireService.send({amount: 1, guid: 123123123, currency: 'tokens', owner: {eth_wallet: '0xaddress'}});
// expect post to be called with the payload
expect(api.post).toBeCalledWith(`api/v1/wire/123123123`, {
expect(api.post).toBeCalledWith(`api/v2/wire/123123123`, {
amount: 1,
method: 'tokens',
method: 'onchain',
payload: {
method: 'onchain',
address: fakePayload.wallet.address,
......@@ -279,12 +237,12 @@ describe('wire service', () => {
BlockchainTokenService.increaseApproval.mockResolvedValue(true);
try {
const result = await WireService.send({amount: 1,recurring: true, guid: 123123123, owner: {eth_wallet: '0xaddress'}});
const result = await WireService.send({amount: 1, recurring: true, guid: 123123123, currency: 'tokens', owner: {eth_wallet: '0xaddress'}});
// expect post to be called with the payload
expect(api.post).toBeCalledWith(`api/v1/wire/123123123`, {
expect(api.post).toBeCalledWith(`api/v2/wire/123123123`, {
amount: 1,
method: 'tokens',
method: 'onchain',
payload: {
method: 'onchain',
address: fakePayload.wallet.address,
......@@ -319,7 +277,7 @@ describe('wire service', () => {
});
it('should throw error when try to send without an address', () => {
return expect(WireService.send({amount: 1, guid: 123123123, owner: {eth_wallet: null}}))
return expect(WireService.send({amount: 1, guid: 123123123, currency: 'tokens', owner: {eth_wallet: null}}))
.rejects.toThrowError('User cannot receive OnChain tokens because they haven\'t setup an OnChain address. Please retry OffChain.');
});
......@@ -327,7 +285,7 @@ describe('wire service', () => {
// return an unexpected payload type
BlockchainWalletService.selectCurrent.mockResolvedValue({type: 'unexpected'});
return expect(WireService.send({amount: 1, guid: 123123123, owner: {eth_wallet: '0xsome'}}))
return expect(WireService.send({amount: 1, guid: 123123123, currency: 'tokens', owner: {eth_wallet: '0xsome'}}))
.rejects.toThrowError('Unknown type');
});
......
......@@ -15,26 +15,30 @@ describe('wire store', () => {
store = new WireStore();
});
it('should set the guid', () => {
it('should set the owner', () => {
const owner = {name: 'someone', guid: '123123'}
// should have a default null
expect(store.guid).toBe(null);
expect(store.owner).toBe(null);
store.setGuid('123123');
store.setOwner(owner);
// should change to the new value
expect(store.guid).toBe('123123');
expect(store.owner).toEqual(owner);
});
it('should set the owner', () => {
it('should set the guid of the owner', () => {
// should have a default null
expect(store.owner).toBe(null);
const owner = {guid: '123123'};
expect(store.guid).toBe(undefined);
store.setOwner({name: 'someone'});
store.setOwner(owner);
// should change to the new value
expect(store.owner).toEqual({name: 'someone'});
expect(store.guid).toBe('123123');
});
it('should set the amount', () => {
// should have a default 1
expect(store.amount).toBe(1);
......@@ -79,17 +83,18 @@ describe('wire store', () => {
})
it('should load the user rewards from the service', async (done) => {
const fakeOwner = {name: 'someone'};
const fakeGuid = '123123';
const fakeOwner = {name: 'someone', guid: '123123'};
const fakeOwnerResponse = {name: 'someone', guid: '123123'};
wireService.userRewards.mockResolvedValue(fakeOwner);
wireService.userRewards.mockResolvedValue(fakeOwnerResponse);
try {
const result = await store.loadUser(fakeGuid);
store.setOwner(fakeOwner);
const result = await store.loadUserRewards();
// should return the owner
expect(result).toEqual(fakeOwner);
expect(result).toEqual(fakeOwnerResponse);
// should set the owner
expect(store.owner).toEqual(fakeOwner);
expect(store.owner).toEqual(fakeOwnerResponse);
} catch (e) {
done.fail(e);
}
......@@ -97,12 +102,11 @@ describe('wire store', () => {
});
it('should not set the owner if load rewards fails', async (done) => {
const fakeGuid = '123123';
wireService.userRewards.mockRejectedValue(new Error('fakeError'));
try {
await store.loadUser(fakeGuid);
await store.loadUserRewards();
done.fail();
} catch (e) {
// should not set the owner
......@@ -128,19 +132,29 @@ describe('wire store', () => {
it('should reset the obvservable values', () => {
store.amount = 2;
store.currency = 'usd';
store.sending = true;
store.owner = {};
store.recurring = true;
store.guid = '123123';
store.showBtc = true;
store.showCardselector = true;
store.loaded = true;
store.errors = [{message:'error'}];
store.reset();
// should reset all
expect(store.amount).toEqual(1);
expect(store.sending).toEqual(false);
expect(store.showBtc).toEqual(false);
expect(store.showCardselector).toEqual(false);
expect(store.loaded).toEqual(false);
expect(store.owner).toEqual(null);
expect(store.currency).toEqual('tokens');
expect(store.errors).toEqual([]);
expect(store.recurring).toEqual(false);
expect(store.guid).toEqual(null);
expect(store.guid).toEqual(undefined);
});
it('should return if already sending', () => {
......@@ -161,6 +175,8 @@ describe('wire store', () => {
() => expect(store.sending).toEqual(true)
);
store.setOwner({guid: '123123', name: 'someone'});
const result = await store.send();
// should return the service call result
......@@ -171,10 +187,12 @@ describe('wire store', () => {
// should call the service
expect(wireService.send).toBeCalledWith({
currency: 'tokens',
amount: store.amount,
guid: store.guid,
owner: store.owner,
recurring: store.recurring
recurring: store.recurring,
paymentMethodId: null
});
done();
......@@ -196,18 +214,20 @@ describe('wire store', () => {
() => expect(store.sending).toEqual(true)
);
await store.send();
store.setOwner({guid: '123123', name: 'someone'});
await store.send();
done.fail('should fail');
} catch (e) {
// should call the service
expect(wireService.send).toBeCalledWith({
currency: 'tokens',
amount: store.amount,
guid: store.guid,
owner: store.owner,
recurring: store.recurring
recurring: store.recurring,
paymentMethodId: null
});
// should set sending in false on finish
......
......@@ -23,7 +23,7 @@ class WireStore {
@observable paymentMethodId: ?string = null;
guid: string;
guid: ?string;
@action
setShowBtc = (value: boolean) => {
......@@ -188,6 +188,7 @@ class WireStore {
@action
reset() {
this.paymentMethodId = null,
this.guid = undefined;
this.amount = 1;
this.showBtc = false;
this.showCardselector = false;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment