Browse Source

[+MOB] WIP - acceptance test that requires a call to an external service

Elisa Cutrin 1 year ago
parent
commit
27159b8d58
1 changed files with 47 additions and 16 deletions
  1. 47 16
      apps/wallet/test/acceptance/sign.test.js

+ 47 - 16
apps/wallet/test/acceptance/sign.test.js

@@ -1,4 +1,5 @@
1 1
 import React from 'react';
2
+import { Text } from 'react-native';
2 3
 import fetchMock from 'fetch-mock';
3 4
 import configureMockStore from 'redux-mock-store';
4 5
 import Enzyme, { shallow } from 'enzyme';
@@ -70,7 +71,6 @@ describe('signing a petition', () => {
70 71
       },
71 72
     };
72 73
 
73
-    // fetchMock.getOnce(initialState.petitionLink.petitionLink, newPetition);
74 74
 
75 75
     store = mockStore(state);
76 76
 
@@ -127,25 +127,56 @@ describe('signing a petition', () => {
127 127
     // THEN I am able to sign
128 128
     expect(wrapper.dive().find(Button).first().prop('enabled')).toEqual(true);
129 129
   });
130
-});
131
-
132
-// NEXT ITERATIONS OF THE TEST:
133
-// Use library cucumber style
134 130
 
131
+  it('should render the petition title', (done) => {
132
+    const petitionTitle = 'My petition';
133
+    const newPetition = {
134
+      title: petitionTitle,
135
+      description: 'world',
136
+      closingDate: 'today',
137
+      id: '1234',
138
+      isEthereum: 'false',
139
+    };
140
+    const state = {
141
+      ...initialState,
142
+      // GIVEN a petition with X attributes
143
+      petition: {
144
+        petition: {
145
+        },
146
+      },
147
+      attributes: {
148
+        isRequiredAttributeEnabled: true,
149
+        optionalAttributesToggleStatus: {
150
+          age: false,
151
+          gender: false,
152
+        },
153
+        // AND I do not have a required attribute
154
+        list: [],
155
+      },
156
+    };
135 157
 
136
-// clearState
158
+    fetchMock.getOnce(state.petitionLink.petitionLink, newPetition);
137 159
 
138
-// before()
160
+    store = mockStore(state);
139 161
 
140
-// GIVEN a petition with X attributes
141
-//     state.config.petitionurl = ''
142
-//     mock fetch getpetition
162
+    // WHEN I review the petition
163
+    const wrapper = shallow(
164
+      <PetitionSummary />,
165
+      { context: { store } },
166
+    );
143 167
 
144
-// AND I am missing some of the required attributes
145
-//     []
168
+    setTimeout(() => {
169
+      wrapper.update();
170
+      console.log('waited one second');
171
+      // THEN I am able to see the petition title
172
+      console.log(store.getActions());
173
+      // console.log(wrapper.update().dive().debug());
146 174
 
147
-// WHEN I review the petition
148
-//     petitionSummary.shallowMount()
175
+      const wrapper2 = wrapper.dive().find(Text).findWhere(n => n.text() === petitionTitle);
176
+      console.log(wrapper2);
149 177
 
150
-// THEN I am not able to sign
151
-//     petitionSummary.find(submitbutton.disabled == true)
178
+      // expect(wrapper2.exists()).toEqual(true);
179
+      done();
180
+    }, 1000);
181
+  });
182
+});