-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #159 from creative-commoners/pulls/4/no-owner
ENH Show save record first text on unsaved owners
- Loading branch information
Showing
8 changed files
with
71 additions
and
7 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.link-field__save-record-first { | ||
padding-top: 7px; | ||
} |
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,54 @@ | ||
/* global jest, test */ | ||
import React from 'react'; | ||
import { render } from '@testing-library/react'; | ||
import { Component as LinkField } from '../LinkField'; | ||
|
||
jest.mock('lib/Backend', () => ({ | ||
get: () => new Promise(() => {}) | ||
})); | ||
|
||
window.ss.config = { | ||
sections: [ | ||
{ | ||
name: 'SilverStripe\\LinkField\\Controllers\\LinkFieldController', | ||
form: { | ||
linkForm: { | ||
dataUrl: 'http://example.com/mock-endpoint' | ||
} | ||
} | ||
} | ||
] | ||
}; | ||
|
||
function makeProps(obj = {}) { | ||
return { | ||
value: 123, | ||
onChange: () => {}, | ||
types: [], | ||
actions: {}, | ||
isMulti: false, | ||
canCreate: true, | ||
ownerID: 123, | ||
ownerClass: 'Page', | ||
ownerRelation: 'MyRelation', | ||
...obj | ||
}; | ||
} | ||
|
||
test('LinkField will render save-record-first div if ownerID is 0', async () => { | ||
const { container } = render(<LinkField {...makeProps({ | ||
ownerID: 0 | ||
})} | ||
/>); | ||
expect(container.querySelectorAll('.link-field__save-record-first')).toHaveLength(1); | ||
expect(container.querySelectorAll('.link-picker')).toHaveLength(0); | ||
}); | ||
|
||
test('LinkField will render link-picker if ownerID is not 0', async () => { | ||
const { container } = render(<LinkField {...makeProps({ | ||
ownerID: 1 | ||
})} | ||
/>); | ||
expect(container.querySelectorAll('.link-field__save-record-first')).toHaveLength(0); | ||
expect(container.querySelectorAll('.link-picker')).toHaveLength(1); | ||
}); |
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