forked from apex-enterprise-patterns/fflib-apex-common
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move some view form text over to labels
Started the view form unit tests
- Loading branch information
1 parent
61a02a3
commit b39e23c
Showing
5 changed files
with
96 additions
and
5 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
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
73 changes: 73 additions & 0 deletions
73
framework/default/ortoo-core/default/lwc/viewAndEditForm/__tests__/viewAndEditForm.test.js
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,73 @@ | ||
import { createElement } from 'lwc'; | ||
import ViewAndEditForm from 'c/viewAndEditForm'; | ||
|
||
describe('c-view-and-edit-form', () => { | ||
afterEach(() => { | ||
// The jsdom instance is shared across test cases in a single file so reset the DOM | ||
while (document.body.firstChild) { | ||
document.body.removeChild(document.body.firstChild); | ||
} | ||
}); | ||
|
||
it('When inEditMode, has a save and cancel button, but no edit', () => { | ||
const element = createElement('c-view-and-edit-form', { | ||
is: ViewAndEditForm | ||
}); | ||
element.inEditMode = true; | ||
document.body.appendChild(element); | ||
|
||
const saveButton = element.shadowRoot.querySelector( '[data-name="save"]' ); | ||
expect( saveButton ).not.toBe( null ); | ||
|
||
const cancelButton = element.shadowRoot.querySelector( '[data-name="cancel"]' ); | ||
expect( cancelButton ).not.toBe( null ); | ||
|
||
const editButton = element.shadowRoot.querySelector( '[data-name="edit"]' ); | ||
expect( editButton ).toBe( null ); | ||
}); | ||
|
||
it('When not inEditMode, has an edit button, but no save or cancel', () => { | ||
const element = createElement('c-view-and-edit-form', { | ||
is: ViewAndEditForm | ||
}); | ||
element.inEditMode = false; | ||
document.body.appendChild(element); | ||
|
||
const saveButton = element.shadowRoot.querySelector( '[data-name="save"]' ); | ||
expect( saveButton ).toBe( null ); | ||
|
||
const cancelButton = element.shadowRoot.querySelector( '[data-name="cancel"]' ); | ||
expect( cancelButton ).toBe( null ); | ||
|
||
const editButton = element.shadowRoot.querySelector( '[data-name="edit"]' ); | ||
expect( editButton ).not.toBe( null ); | ||
}); | ||
|
||
it('When inEditMode, has an editForm slot but no viewForm slot', () => { | ||
const element = createElement('c-view-and-edit-form', { | ||
is: ViewAndEditForm | ||
}); | ||
element.inEditMode = true; | ||
document.body.appendChild(element); | ||
|
||
const viewForm = element.shadowRoot.querySelector( 'slot[name="viewForm"]' ); | ||
expect( viewForm ).toBe( null ); | ||
|
||
const editForm = element.shadowRoot.querySelector( 'slot[name="editForm"]' ); | ||
expect( editForm ).not.toBe( null ); | ||
}); | ||
|
||
it('When not inEditMode, has a viewForm slot but no editForm slot', () => { | ||
const element = createElement('c-view-and-edit-form', { | ||
is: ViewAndEditForm | ||
}); | ||
element.inEditMode = false; | ||
document.body.appendChild(element); | ||
|
||
const viewForm = element.shadowRoot.querySelector( 'slot[name="viewForm"]' ); | ||
expect( viewForm ).not.toBe( null ); | ||
|
||
const editForm = element.shadowRoot.querySelector( 'slot[name="editForm"]' ); | ||
expect( editForm ).toBe( null ); | ||
}); | ||
}); |
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
14 changes: 10 additions & 4 deletions
14
framework/default/ortoo-core/default/lwc/viewAndEditForm/viewAndEditForm.js
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