-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(02.렌더링/05):
isNodeChanged()
테스트 코드 추가
- Loading branch information
Showing
2 changed files
with
62 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
const isNodeChanged = () => {}; | ||
|
||
export default isNodeChanged; |
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,59 @@ | ||
import isNodeChanged from './isNodeChanged'; | ||
|
||
describe('isNodeChanged', () => { | ||
test('두 노드의 어트리뷰트, 텍스트 컨텐츠가 동일하다면 false 반환', () => { | ||
const node1 = document.createElement('div'); | ||
node1.setAttribute('class', 'container'); | ||
node1.textContent = 'Hello, world!'; | ||
|
||
const node2 = document.createElement('div'); | ||
node2.setAttribute('class', 'container'); | ||
node2.textContent = 'Hello, world!'; | ||
|
||
expect(isNodeChanged(node1, node2)).toBe(false); | ||
}); | ||
|
||
test('두 노드가 다른 어트리뷰트를 가지면 true 반환', () => { | ||
const node1 = document.createElement('div'); | ||
node1.setAttribute('class', 'container'); | ||
node1.textContent = 'Hello, world!'; | ||
|
||
const node2 = document.createElement('div'); | ||
node2.setAttribute('class', 'wrapper'); | ||
node2.setAttribute('id', 'myDiv'); | ||
node2.textContent = 'Hello, world!'; | ||
|
||
expect(isNodeChanged(node1, node2)).toBe(true); | ||
}); | ||
|
||
test('두 노드가 같은 어트리뷰트를 갖지만 어트리뷰트의 값이 다르면 true 반환', () => { | ||
const node1 = document.createElement('div'); | ||
node1.setAttribute('class', 'container'); | ||
node1.textContent = 'Hello, world!'; | ||
|
||
const node2 = document.createElement('div'); | ||
node2.setAttribute('class', 'wrapper'); | ||
node2.textContent = 'Hello, world!'; | ||
|
||
expect(isNodeChanged(node1, node2)).toBe(true); | ||
}); | ||
|
||
test('두 노드가 다른 텍스트 컨텐츠를 가지면 true 반환', () => { | ||
const node1 = document.createElement('div'); | ||
node1.setAttribute('class', 'container'); | ||
node1.textContent = 'Hello, world!'; | ||
|
||
const node2 = document.createElement('div'); | ||
node2.setAttribute('class', 'container'); | ||
node2.textContent = 'Hello, GitHub Copilot!'; | ||
|
||
expect(isNodeChanged(node1, node2)).toBe(true); | ||
}); | ||
|
||
test('두 노드가 어트리뷰트, 텍스트 컨텐츠를 가지지 않으면 false 반환', () => { | ||
const node1 = document.createElement('div'); | ||
const node2 = document.createElement('div'); | ||
|
||
expect(isNodeChanged(node1, node2)).toBe(false); | ||
}); | ||
}); |