Skip to content

Commit

Permalink
remove unnecessary comments
Browse files Browse the repository at this point in the history
  • Loading branch information
aiste-tamo committed Oct 23, 2023
1 parent 373f01b commit 64d37a1
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 10 deletions.
21 changes: 11 additions & 10 deletions spec/autocomplete.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ describe('history', () => {
it('should see results after typing', async () => {
const user = userEvent.setup()
handleAutocomplete()

await user.type(screen.getByTestId('input'), 're')
await waitFor(
() => {
Expand All @@ -265,6 +266,7 @@ describe('history', () => {
it('should see history on empty input', async () => {
const user = userEvent.setup()
handleAutocomplete()

await user.clear(screen.getByTestId('input'))
await user.type(screen.getByTestId('input'), 're')
await user.click(screen.getByTestId('search-button'))
Expand All @@ -279,6 +281,7 @@ describe('history', () => {
it('should show history keyword', async () => {
const user = userEvent.setup()
handleAutocomplete()

await user.clear(screen.getByTestId('input'))
await user.type(screen.getByTestId('input'), 're')
await user.click(screen.getByTestId('search-button'))
Expand All @@ -296,7 +299,6 @@ describe('history', () => {
// Mock console.log
const consoleSpy = jest.spyOn(console, 'log')

// Add multiple keywords to history
await user.type(screen.getByTestId('input'), 're')
await user.click(screen.getByTestId('search-button'))
await user.clear(screen.getByTestId('input'))
Expand All @@ -305,30 +307,26 @@ describe('history', () => {
await user.click(screen.getByTestId('search-button'))
await user.clear(screen.getByTestId('input'))

// Delete previous console.logs and add new console.log
consoleSpy.mockClear()

// Navigate and select history keywords
await user.keyboard('{arrowdown}') // Navigate down
await user.keyboard('{arrowdown}') // Navigate down
await user.keyboard('{arrowup}') // Navigate up
await user.keyboard('{enter}') // Select and submit
await user.keyboard('{arrowdown}')
await user.keyboard('{arrowdown}')
await user.keyboard('{arrowup}')
await user.keyboard('{enter}')

// Ensure the selected query content is logged
expect(consoleSpy).toHaveBeenCalledWith(
'Submitted search with query: re',
)

// Ensure additional console.log calls are not made
expect(consoleSpy).toHaveBeenCalledTimes(1)

// Restore the original console.log after the test
consoleSpy.mockRestore()
})

it('should show two history keywords', async () => {
const user = userEvent.setup()
handleAutocomplete()

await user.clear(screen.getByTestId('input'))
await user.type(screen.getByTestId('input'), 're')
await user.click(screen.getByTestId('search-button'))
Expand All @@ -349,13 +347,15 @@ describe('history', () => {
it('should clear history keyword', async () => {
const user = userEvent.setup()
handleAutocomplete()

await user.clear(screen.getByTestId('input'))
await user.type(screen.getByTestId('input'), 're')
await user.keyboard('{enter}')
await user.clear(screen.getByTestId('input'))
await user.type(screen.getByTestId('input'), 'black')
await user.keyboard('{enter}')
await user.clear(screen.getByTestId('input'))

await waitFor(async () => {
const removeHistoryElement = screen.queryByTestId(
'remove-history-black',
Expand All @@ -372,6 +372,7 @@ describe('history', () => {
it('should clear history', async () => {
const user = userEvent.setup()
handleAutocomplete()

await user.clear(screen.getByTestId('input'))
await user.type(screen.getByTestId('input'), 're')
await user.click(screen.getByTestId('search-button'))
Expand Down
9 changes: 9 additions & 0 deletions spec/liquid.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,9 @@ describe('fromRemoteLiquidTemplate', () => {
it('should see results after typing', async () => {
const user = userEvent.setup()
handleAutocomplete()

await user.type(screen.getByTestId('input'), 're')

await waitFor(
() => {
expect(screen.getByTestId('dropdown')).toBeVisible()
Expand All @@ -397,6 +399,7 @@ describe('fromRemoteLiquidTemplate', () => {
it('should see history on empty input', async () => {
const user = userEvent.setup()
handleAutocomplete()

await user.clear(screen.getByTestId('input'))
await user.type(screen.getByTestId('input'), 're')
await user.click(screen.getByTestId('search-button'))
Expand All @@ -411,6 +414,7 @@ describe('fromRemoteLiquidTemplate', () => {
it('should show history keyword', async () => {
const user = userEvent.setup()
handleAutocomplete()

await user.clear(screen.getByTestId('input'))
await user.type(screen.getByTestId('input'), 're')
await user.click(screen.getByTestId('search-button'))
Expand Down Expand Up @@ -455,9 +459,11 @@ describe('fromRemoteLiquidTemplate', () => {
it('should show two history keywords', async () => {
const user = userEvent.setup()
handleAutocomplete()

await user.clear(screen.getByTestId('input'))
await user.type(screen.getByTestId('input'), 're')
await user.click(screen.getByTestId('search-button'))

await user.clear(screen.getByTestId('input'))
await user.type(screen.getByTestId('input'), 'black')
await user.click(screen.getByTestId('search-button'))
Expand All @@ -475,13 +481,15 @@ describe('fromRemoteLiquidTemplate', () => {
it('should clear history keyword', async () => {
const user = userEvent.setup()
handleAutocomplete()

await user.clear(screen.getByTestId('input'))
await user.type(screen.getByTestId('input'), 're')
await user.keyboard('{enter}')
await user.clear(screen.getByTestId('input'))
await user.type(screen.getByTestId('input'), 'black')
await user.keyboard('{enter}')
await user.clear(screen.getByTestId('input'))

await waitFor(async () => {
const removeHistoryElement = screen.queryByTestId(
'remove-history-black',
Expand All @@ -498,6 +506,7 @@ describe('fromRemoteLiquidTemplate', () => {
it('should clear history', async () => {
const user = userEvent.setup()
handleAutocomplete()

await user.clear(screen.getByTestId('input'))
await user.type(screen.getByTestId('input'), 're')
await user.click(screen.getByTestId('search-button'))
Expand Down

0 comments on commit 64d37a1

Please sign in to comment.