Skip to content

Commit

Permalink
Remove tests for legacy droppers
Browse files Browse the repository at this point in the history
  • Loading branch information
jimchamp committed Nov 17, 2023
1 parent afccfdd commit 2b9ed8f
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 102 deletions.
4 changes: 0 additions & 4 deletions bundlesize.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,6 @@
"path": "static/build/tabs.*.js",
"maxSize": "5KB"
},
{
"path": "static/build/lists.*.js",
"maxSize": "8KB"
},
{
"path": "static/build/all.js",
"maxSize": "130KB"
Expand Down
12 changes: 0 additions & 12 deletions tests/unit/js/html-test-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,18 +186,6 @@ export const checkInForm = `
</div>
`

export const readingLogDropperForm = `
<div id="dropper">
<form class="readingLog">
<input type="hidden" name="bookshelf_id" value="1">
<input type="hidden" name="action" value="">
</form>
<form id="remove-from-list">
<input type="hidden" name="bookshelf_id">
<button class="hidden">Remove From Shelf</button>
</form>
</div>
`
export const readClassification = `
<fieldset class="major" id="classifications" data-config="{&quot;Please select a classification.&quot;: &quot;Please select a classification.&quot;, &quot;You need to give a value to CLASS.&quot;: &quot;You need to give a value to CLASS.&quot;}">
<legend>Classifications</legend>
Expand Down
86 changes: 0 additions & 86 deletions tests/unit/js/lists.test.js
Original file line number Diff line number Diff line change
@@ -1,93 +1,7 @@
import { clearCreateListForm, syncReadingLogDropdownRemoveWithPrimaryButton } from '../../../openlibrary/plugins/openlibrary/js/lists/index.js';
import { createActiveShowcaseItem, ShowcaseItem } from '../../../openlibrary/plugins/openlibrary/js/lists/ShowcaseItem.js';
import { CreateListForm } from '../../../openlibrary/plugins/openlibrary/js/my-books/CreateListForm.js'

import { readingLogDropperForm } from './html-test-data';
import { listCreationForm, filledListCreationForm, showcaseI18nInput, subjectShowcase, authorShowcase, workShowcase, editionShowcase, activeListShowcase, listsSectionShowcase } from './sample-html/lists-test-data'

// Start : Legacy tests
describe('clearCreateListForm', () => {
test('Clears form when called', () => {
// Set up
document.body.innerHTML = filledListCreationForm
const listName = document.querySelector('#list_label')
const listDesc = document.querySelector('#list_desc')

// Form should be filled initially
expect(listName.value.length).toBeGreaterThan(0)
expect(listDesc.value.length).toBeGreaterThan(0)

// Test clearing the form
clearCreateListForm()
expect(listName.value.length).toBe(0)
expect(listDesc.value.length).toBe(0)
})
})

describe('syncReadingLogDropdownRemoveWithPrimaryButton', () => {
test('displays remove-from-shelf button only if book is on a shelf', () => {
// Setup
document.body.innerHTML = readingLogDropperForm
const dropper = document.querySelector('#dropper');
const readingLogForm = document.querySelector('.readingLog')

// Add "remove" to the action to simulate a book on the shelf
document.querySelector('[name=action]').value = 'remove'

// Test
syncReadingLogDropdownRemoveWithPrimaryButton(dropper, readingLogForm);

// Verify
const removalButton = dropper.querySelector('#remove-from-list button');
expect(removalButton.classList.contains('hidden')).toBe(false);

// Teardown
document.body.innerHTML = '';
});

test('hides remove-from-shelf button if book is not on a shelf', () => {
// Setup
document.body.innerHTML = readingLogDropperForm
const dropper = document.querySelector('#dropper');
const readingLogForm = document.querySelector('.readingLog')

// Add "add" to the action to simulate a book off the shelf
document.querySelector('[name=action]').value = 'add'

// Test
syncReadingLogDropdownRemoveWithPrimaryButton(dropper, readingLogForm);

// Verify
const removalButton = dropper.querySelector('#remove-from-list button');
expect(removalButton.classList.contains('hidden')).toBe(true);

// Teardown
document.body.innerHTML = '';
});

test('syncs bookshelf_id in remove-from-list form with primaryButton', () => {
// Setup
document.body.innerHTML = readingLogDropperForm
const dropper = document.querySelector('#dropper');
const readingLogForm = document.querySelector('.readingLog')

// Sync the shelf for removal.
document.querySelector('[name=bookshelf_id]').value = '2'

// Test
syncReadingLogDropdownRemoveWithPrimaryButton(dropper, readingLogForm);

// Verify
const removalForm = dropper.querySelector('#remove-from-list')
const bookshelfIdInput = removalForm.querySelector('[name=bookshelf_id]');
expect(bookshelfIdInput.value).toBe('2');

// Teardown
document.body.innerHTML = '';
});
});
// End : Legacy tests

describe('CreateListForm class tests', () => {
test('CreateListForm fields correctly set', () => {
document.body.innerHTML = listCreationForm
Expand Down

0 comments on commit 2b9ed8f

Please sign in to comment.