Skip to content
This repository has been archived by the owner on Jan 31, 2023. It is now read-only.

Commit

Permalink
Created skeleton screen for creating a new transaction
Browse files Browse the repository at this point in the history
Signed-off-by: Erin Hughes <[email protected]>
  • Loading branch information
erin-hughes committed Oct 31, 2019
1 parent d3c93b3 commit b6534a2
Show file tree
Hide file tree
Showing 21 changed files with 709 additions and 76 deletions.
100 changes: 60 additions & 40 deletions cypress/integration/transaction_view.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,57 +2,77 @@
chai.should();
describe('Cypress', () => {

const mockMessage: {path: string, state: {smartContracts: Array<string>, activeSmartContract: string}} = {
path: 'transaction',
state: {
smartContracts: ['[email protected]', '[email protected]'],
activeSmartContract: '[email protected]'
}
};

beforeEach(() => {
cy.visit('build/index.html').then((window: Window) => {
window.postMessage(mockMessage, '*');
describe('Transaction home screen', () => {

const mockMessage: {path: string, state: {smartContracts: Array<string>, activeSmartContract: string}} = {
path: 'transaction',
state: {
smartContracts: ['[email protected]', '[email protected]'],
activeSmartContract: '[email protected]'
}
};

beforeEach(() => {
cy.visit('build/index.html').then((window: Window) => {
window.postMessage(mockMessage, '*');
});
});

});
it('should correctly display the currently active smart contract', () => {
cy.get('.titles-container > span').contains('[email protected]');
cy.get('.contents-left > p > span').contains('[email protected]');
});

it('is working', () => {
cy.get('#create-button').click();
cy.focused().should('have.id', 'create-button');
it('should correctly display the list of instantiated smart contracts', () => {
cy.get('.contents-left > ul > li:first')
.contains('[email protected]')
.should('have.class', 'smart-contract-item disabled-smart-contract');

cy.get('#import-button').click();
cy.focused().should('have.id', 'import-button');
});
cy.get('.contents-left > ul > li:nth-of-type(2)')
.contains('[email protected]')
.should('have.class', 'smart-contract-item clickable-smart-contract');
});

it('should correctly display the currently active smart contract', () => {
cy.get('.titles-container > span').contains('[email protected]');
cy.get('.contents-left > p > span').contains('[email protected]');
});
it('should allow switching between smart contracts', () => {
cy.get('.contents-left > ul > li:nth-of-type(2)').click();

cy.get('.titles-container > span').contains('[email protected]');
cy.get('.contents-left > p > span').contains('[email protected]');

it('should correctly display the list of instantiated smart contracts', () => {
cy.get('.contents-left > ul > li:first')
.contains('[email protected]')
.should('have.class', 'smart-contract-item disabled-smart-contract');
cy.get('.contents-left > ul > li:first')
.contains('[email protected]')
.should('have.class', 'smart-contract-item clickable-smart-contract');

cy.get('.contents-left > ul > li:nth-of-type(2)')
.contains('[email protected]')
.should('have.class', 'smart-contract-item clickable-smart-contract');
cy.get('.contents-left > ul > li:nth-of-type(2)')
.contains('[email protected]')
.should('have.class', 'smart-contract-item disabled-smart-contract');
});

it('should navigate to the create screen', () => {
cy.get('#create-button').click();
cy.url().should('include', '/transaction/create');
});
});

it('should allow switching between smart contracts', () => {
cy.get('.contents-left > ul > li:nth-of-type(2)').click();
describe('Transaction create screen', () => {

cy.get('.titles-container > span').contains('[email protected]');
cy.get('.contents-left > p > span').contains('[email protected]');
beforeEach(() => {

cy.get('.contents-left > ul > li:first')
.contains('[email protected]')
.should('have.class', 'smart-contract-item clickable-smart-contract');
const mockMessage: {path: string, state: {smartContracts: Array<string>, activeSmartContract: string}} = {
path: 'transaction/create',
state: {
smartContracts: ['[email protected]', '[email protected]'],
activeSmartContract: '[email protected]'
}
};

cy.get('.contents-left > ul > li:nth-of-type(2)')
.contains('[email protected]')
.should('have.class', 'smart-contract-item disabled-smart-contract');
});
cy.visit('build/index.html').then((window: Window) => {
window.postMessage(mockMessage, '*');
});
});

it('is a transaction create screen', () => {
expect(true).to.equal(true);
});
});
});
28 changes: 28 additions & 0 deletions enzyme/tests/TransactionCreate.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@

import React from 'react';
import renderer from 'react-test-renderer';
import TransactionCreate from '../../src/components/TransactionCreate/TransactionCreate';
import chai from 'chai';
import sinon from 'sinon';
import sinonChai from 'sinon-chai';
chai.should();
chai.use(sinonChai);

describe('TransactionCreate component', () => {
let mySandbox: sinon.SinonSandbox;

beforeEach(async () => {
mySandbox = sinon.createSandbox();
});

afterEach(async () => {
mySandbox.restore();
});

it('should render the expected snapshot', async () => {
const component: any = renderer
.create(<TransactionCreate/>)
.toJSON();
expect(component).toMatchSnapshot();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
import React from 'react';
import renderer from 'react-test-renderer';
import { mount } from 'enzyme';
import TransactionViewPage from '../../src/components/TransactionViewPage/TransactionViewPage';
import TransactionHome from '../../src/components/TransactionHome/TransactionHome';
import chai from 'chai';
import sinon from 'sinon';
import sinonChai from 'sinon-chai';
chai.should();
chai.use(sinonChai);

describe('TransactionViewPage component', () => {
describe('TransactionHome component', () => {

let mySandBox: sinon.SinonSandbox;
let switchSmartContractSpy: sinon.SinonSpy;
Expand All @@ -21,7 +21,7 @@ describe('TransactionViewPage component', () => {

beforeEach(async () => {
mySandBox = sinon.createSandbox();
switchSmartContractSpy = mySandBox.spy(TransactionViewPage.prototype, 'switchSmartContract');
switchSmartContractSpy = mySandBox.spy(TransactionHome.prototype, 'switchSmartContract');
});

afterEach(async () => {
Expand All @@ -30,20 +30,20 @@ describe('TransactionViewPage component', () => {

it('should render the expected snapshot', async () => {
const component: any = renderer
.create(<TransactionViewPage messageData={mockState}/>)
.create(<TransactionHome messageData={mockState}/>)
.toJSON();
expect(component).toMatchSnapshot();
});

it('should change the active smart contract if another contract is selected', async () => {
const component: any = mount(<TransactionViewPage messageData={mockState}/>);
const component: any = mount(<TransactionHome messageData={mockState}/>);
component.find('li').at(1).simulate('click');
switchSmartContractSpy.should.have.been.calledOnce;
expect(component.state().activeSmartContract).toBe('[email protected]');
});

it('should do nothing if the current smart contract is selected', async () => {
const component: any = mount(<TransactionViewPage messageData={mockState}/>);
const component: any = mount(<TransactionHome messageData={mockState}/>);
component.find('li').at(0).simulate('click');
switchSmartContractSpy.should.not.have.been.called;
expect(component.state().activeSmartContract).toBe('[email protected]');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import React from 'react';
import renderer from 'react-test-renderer';
import TransactionViewSidebar from '../../src/components/TransactionViewSidebar/TransactionViewSidebar';
import TransactionSidebar from '../../src/components/TransactionSidebar/TransactionSidebar';
import chai from 'chai';
import sinon from 'sinon';
import sinonChai from 'sinon-chai';
chai.should();
chai.use(sinonChai);

describe('TransactionViewSidebar component', () => {
describe('TransactionSidebar component', () => {

let mySandBox: sinon.SinonSandbox;

Expand All @@ -21,7 +21,7 @@ describe('TransactionViewSidebar component', () => {

it('should render the expected snapshot', async () => {
const component: any = renderer
.create(<TransactionViewSidebar/>)
.create(<TransactionSidebar/>)
.toJSON();
expect(component).toMatchSnapshot();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import React from 'react';
import renderer from 'react-test-renderer';
import { mount } from 'enzyme';
import SidebarPanel from '../../src/components/TransactionViewSidebarPanel/TransactionViewSidebarPanel';
import SidebarPanel from '../../src/components/TransactionSidebarPanel/TransactionSidebarPanel';
import chai from 'chai';
import sinon from 'sinon';
import sinonChai from 'sinon-chai';
Expand Down Expand Up @@ -42,11 +42,11 @@ describe('SidebarPanel component', () => {
expect(component).toMatchSnapshot();
});

it('will one day allow a user to create a new transaction', async () => {
const createTxnSpy: sinon.SinonSpy = sinon.spy(SidebarPanel.prototype, 'createTxn');
it('should navigate to the create screen', async () => {
const dispatchEventSpy: sinon.SinonSpy = sinon.spy(EventTarget.prototype, 'dispatchEvent');
const component: any = mount(<SidebarPanel panelType='buttons'/>);
component.find('#create-button').at(1).simulate('click');
createTxnSpy.should.have.been.called;
dispatchEventSpy.should.have.been.called;
});

it('will one day allow a user to create a new transaction', async () => {
Expand Down
Loading

0 comments on commit b6534a2

Please sign in to comment.