Skip to content
This repository has been archived by the owner on Nov 28, 2022. It is now read-only.

Commit

Permalink
clean up test helper duplication with partial application
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinansfield committed Nov 10, 2017
1 parent 7921212 commit 8ef2739
Showing 1 changed file with 9 additions and 21 deletions.
30 changes: 9 additions & 21 deletions tests/acceptance/settings/general-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -347,35 +347,23 @@ describe('Acceptance: Settings - General', function () {
});

it('handles social blog settings correctly', async function () {
let testFacebookValidation = async function(input, expectedValue, expectedError = '') {
await fillIn('[data-test-facebook-input]', input);
await triggerEvent('[data-test-facebook-input]', 'blur');
let testSocialInput = async function(type, input, expectedValue, expectedError = '') {
await fillIn(`[data-test-${type}-input]`, input);
await triggerEvent(`[data-test-${type}-input]`, 'blur');

expect(
find('[data-test-facebook-input]').val(),
`facebook value for ${input}`
find(`[data-test-${type}-input]`).val(),
`${type} value for ${input}`
).to.equal(expectedValue);

expect(
find('[data-test-facebook-error]').text().trim(),
`facebook validation response for ${input}`
find(`[data-test-${type}-error]`).text().trim(),
`${type} validation response for ${input}`
).to.equal(expectedError);
};

let testTwitterValidation = async function(input, expectedValue, expectedError = '') {
await fillIn('[data-test-twitter-input]', input);
await triggerEvent('[data-test-twitter-input]', 'blur');

expect(
find('[data-test-twitter-input]').val(),
`twitter value for ${input}`
).to.equal(expectedValue);

expect(
find('[data-test-twitter-error]').text().trim(),
`twitter validation response for ${input}`
).to.equal(expectedError);
};
let testFacebookValidation = async (...args) => testSocialInput('facebook', ...args);
let testTwitterValidation = async (...args) => testSocialInput('twitter', ...args);

await visit('/settings/general');
await click('[data-test-toggle-social]');
Expand Down

0 comments on commit 8ef2739

Please sign in to comment.