-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
689deba
commit 861b1ee
Showing
4 changed files
with
205 additions
and
189 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,18 @@ | ||
import { render, screen } from '@testing-library/react'; | ||
import App from './App'; | ||
|
||
test('renders add task button', () => { | ||
// Mock console.info method | ||
console.info = jest.fn(); | ||
describe('App', () => { | ||
|
||
render(<App />); | ||
const addButton = screen.getByText(/Add Task/i); | ||
expect(addButton).toBeInTheDocument(); | ||
test('renders add task button', () => { | ||
// Mock console.info method | ||
console.info = jest.fn(); | ||
|
||
render(<App />); | ||
const addButton = screen.getByText(/Add Task/i); | ||
expect(addButton).toBeInTheDocument(); | ||
|
||
// Verify that console.info was called | ||
expect(console.info).toHaveBeenCalled(); | ||
}); | ||
|
||
// Verify that console.info was called | ||
expect(console.info).toHaveBeenCalled(); | ||
}); |
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 |
---|---|---|
@@ -1,66 +1,70 @@ | ||
import { objectsAreEqual, objectArraysAreEqual } from './logicUtils'; | ||
|
||
test('objectsAreEqual returns true for equal objects', () => { | ||
const obj1 = { name: 'John', age: 30 }; | ||
const obj2 = { name: 'John', age: 30 }; | ||
expect(objectsAreEqual(obj1, obj2)).toBe(true); | ||
}); | ||
describe('logicUtils', () => { | ||
|
||
test('objectsAreEqual returns false for objects with different properties', () => { | ||
const obj1 = { name: 'John', age: 30 }; | ||
const obj2 = { name: 'John', age: 30, city: 'New York' }; | ||
expect(objectsAreEqual(obj1, obj2)).toBe(false); | ||
}); | ||
test('objectsAreEqual returns true for equal objects', () => { | ||
const obj1 = { name: 'John', age: 30 }; | ||
const obj2 = { name: 'John', age: 30 }; | ||
expect(objectsAreEqual(obj1, obj2)).toBe(true); | ||
}); | ||
|
||
test('objectsAreEqual returns false for objects with different property values', () => { | ||
const obj1 = { name: 'John', age: 30 }; | ||
const obj2 = { name: 'John', age: 40 }; | ||
expect(objectsAreEqual(obj1, obj2)).toBe(false); | ||
}); | ||
test('objectsAreEqual returns false for objects with different properties', () => { | ||
const obj1 = { name: 'John', age: 30 }; | ||
const obj2 = { name: 'John', age: 30, city: 'New York' }; | ||
expect(objectsAreEqual(obj1, obj2)).toBe(false); | ||
}); | ||
|
||
test('objectsAreEqual returns false for objects with different number of properties', () => { | ||
const obj1 = { name: 'John', age: 30 }; | ||
const obj2 = { name: 'John' }; | ||
expect(objectsAreEqual(obj1, obj2)).toBe(false); | ||
}); | ||
test('objectsAreEqual returns false for objects with different property values', () => { | ||
const obj1 = { name: 'John', age: 30 }; | ||
const obj2 = { name: 'John', age: 40 }; | ||
expect(objectsAreEqual(obj1, obj2)).toBe(false); | ||
}); | ||
|
||
test('objectArraysAreEqual returns true for equal arrays of objects', () => { | ||
const arr1 = [ | ||
{ id: 1, name: 'John', age: 30 }, | ||
{ id: 2, name: 'Jane', age: 25 }, | ||
{ id: 3, name: 'Bob', age: 40 } | ||
]; | ||
const arr2 = [ | ||
{ id: 1, name: 'John', age: 30 }, | ||
{ id: 2, name: 'Jane', age: 25 }, | ||
{ id: 3, name: 'Bob', age: 40 } | ||
]; | ||
expect(objectArraysAreEqual(arr1, arr2)).toBe(true); | ||
}); | ||
test('objectsAreEqual returns false for objects with different number of properties', () => { | ||
const obj1 = { name: 'John', age: 30 }; | ||
const obj2 = { name: 'John' }; | ||
expect(objectsAreEqual(obj1, obj2)).toBe(false); | ||
}); | ||
|
||
test('objectArraysAreEqual returns false for arrays with different lengths', () => { | ||
const arr1 = [ | ||
{ id: 1, name: 'John', age: 30 }, | ||
{ id: 2, name: 'Jane', age: 25 }, | ||
{ id: 3, name: 'Bob', age: 40 } | ||
]; | ||
const arr2 = [ | ||
{ id: 1, name: 'John', age: 30 }, | ||
{ id: 2, name: 'Jane', age: 25 } | ||
]; | ||
expect(objectArraysAreEqual(arr1, arr2)).toBe(false); | ||
}); | ||
test('objectArraysAreEqual returns true for equal arrays of objects', () => { | ||
const arr1 = [ | ||
{ id: 1, name: 'John', age: 30 }, | ||
{ id: 2, name: 'Jane', age: 25 }, | ||
{ id: 3, name: 'Bob', age: 40 } | ||
]; | ||
const arr2 = [ | ||
{ id: 1, name: 'John', age: 30 }, | ||
{ id: 2, name: 'Jane', age: 25 }, | ||
{ id: 3, name: 'Bob', age: 40 } | ||
]; | ||
expect(objectArraysAreEqual(arr1, arr2)).toBe(true); | ||
}); | ||
|
||
test('objectArraysAreEqual returns false for arrays with different objects', () => { | ||
const arr1 = [ | ||
{ id: 1, name: 'John', age: 30 }, | ||
{ id: 2, name: 'Jane', age: 25 }, | ||
{ id: 3, name: 'Bob', age: 40 } | ||
]; | ||
const arr2 = [ | ||
{ id: 1, name: 'John', age: 30 }, | ||
{ id: 2, name: 'Jane', age: 35 }, | ||
{ id: 3, name: 'Bob', age: 40 } | ||
]; | ||
expect(objectArraysAreEqual(arr1, arr2)).toBe(false); | ||
}); | ||
test('objectArraysAreEqual returns false for arrays with different lengths', () => { | ||
const arr1 = [ | ||
{ id: 1, name: 'John', age: 30 }, | ||
{ id: 2, name: 'Jane', age: 25 }, | ||
{ id: 3, name: 'Bob', age: 40 } | ||
]; | ||
const arr2 = [ | ||
{ id: 1, name: 'John', age: 30 }, | ||
{ id: 2, name: 'Jane', age: 25 } | ||
]; | ||
expect(objectArraysAreEqual(arr1, arr2)).toBe(false); | ||
}); | ||
|
||
test('objectArraysAreEqual returns false for arrays with different objects', () => { | ||
const arr1 = [ | ||
{ id: 1, name: 'John', age: 30 }, | ||
{ id: 2, name: 'Jane', age: 25 }, | ||
{ id: 3, name: 'Bob', age: 40 } | ||
]; | ||
const arr2 = [ | ||
{ id: 1, name: 'John', age: 30 }, | ||
{ id: 2, name: 'Jane', age: 35 }, | ||
{ id: 3, name: 'Bob', age: 40 } | ||
]; | ||
expect(objectArraysAreEqual(arr1, arr2)).toBe(false); | ||
}); | ||
|
||
}); |
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 |
---|---|---|
@@ -1,41 +1,45 @@ | ||
import { hasNew, hasReady } from './taskUtils'; | ||
|
||
describe('hasNew', () => { | ||
test('should return false for empty list', () => { | ||
const tasks = []; | ||
const result = hasNew(tasks); | ||
expect(result).toBe(false); | ||
}); | ||
|
||
test('should return false for list with no new items', () => { | ||
const tasks = [{ id: 0, text: 'task1', status: "ready" }]; | ||
const result = hasNew(tasks); | ||
expect(result).toBe(false); | ||
}); | ||
|
||
test('should return true for list with new items', () => { | ||
const tasks = [{ id: 0, text: 'task1', status: "new" }]; | ||
const result = hasNew(tasks); | ||
expect(result).toBe(true); | ||
}); | ||
}); | ||
describe('taskUtils', () => { | ||
|
||
describe('hasReady', () => { | ||
test('should return false for empty list', () => { | ||
const tasks = []; | ||
const result = hasReady(tasks); | ||
expect(result).toBe(false); | ||
describe('hasNew', () => { | ||
test('should return false for empty list', () => { | ||
const tasks = []; | ||
const result = hasNew(tasks); | ||
expect(result).toBe(false); | ||
}); | ||
|
||
test('should return false for list with no new items', () => { | ||
const tasks = [{ id: 0, text: 'task1', status: "ready" }]; | ||
const result = hasNew(tasks); | ||
expect(result).toBe(false); | ||
}); | ||
|
||
test('should return true for list with new items', () => { | ||
const tasks = [{ id: 0, text: 'task1', status: "new" }]; | ||
const result = hasNew(tasks); | ||
expect(result).toBe(true); | ||
}); | ||
}); | ||
|
||
test('should return false for list with no ready items', () => { | ||
const tasks = [{ id: 0, text: 'task1', status: "new" }]; | ||
const result = hasReady(tasks); | ||
expect(result).toBe(false); | ||
}); | ||
|
||
test('should return true for list with ready items', () => { | ||
const tasks = [{ id: 0, text: 'task1', status: "ready" }]; | ||
const result = hasReady(tasks); | ||
expect(result).toBe(true); | ||
|
||
describe('hasReady', () => { | ||
test('should return false for empty list', () => { | ||
const tasks = []; | ||
const result = hasReady(tasks); | ||
expect(result).toBe(false); | ||
}); | ||
|
||
test('should return false for list with no ready items', () => { | ||
const tasks = [{ id: 0, text: 'task1', status: "new" }]; | ||
const result = hasReady(tasks); | ||
expect(result).toBe(false); | ||
}); | ||
|
||
test('should return true for list with ready items', () => { | ||
const tasks = [{ id: 0, text: 'task1', status: "ready" }]; | ||
const result = hasReady(tasks); | ||
expect(result).toBe(true); | ||
}); | ||
}); | ||
}); | ||
|
||
}); |
Oops, something went wrong.