This repository has been archived by the owner on Jan 31, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 157
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Created skeleton screen for creating a new transaction
Signed-off-by: Erin Hughes <[email protected]>
- Loading branch information
1 parent
d3c93b3
commit b6534a2
Showing
21 changed files
with
709 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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; | ||
|
@@ -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 () => { | ||
|
@@ -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]'); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.