Repository navigation
Expand file tree
/
Copy pathindex.test.js
More file actions
63 lines (54 loc) · 1.89 KB
/
Copy pathindex.test.js
File metadata and controls
63 lines (54 loc) · 1.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import '@testing-library/jest-dom/extend-expect';
import { JSDOM } from 'jsdom';
import fs from 'fs';
import path from 'path';
import { isPropertySetInCss, isMediaRuleCorrect } from './utility.js';
const html = fs.readFileSync(path.resolve(__dirname, './index.html'), 'utf8');
const css = fs.readFileSync(path.resolve(__dirname, './index.css'), 'utf8');
const parts = css.split('@media');
const mediaQuery = parts[1];
let dom;
let container;
describe('index.html', () => {
beforeEach(() => {
dom = new JSDOM(html, { runScripts: 'dangerously' });
container = dom.window.document.body;
});
it('css-1 media query tanımlanmış', () => {
expect(parts.length).toBe(2);
});
it('css-1 media query maks genişlik 500px için ayarlanmış', () => {
expect(isMediaRuleCorrect(mediaQuery, 'max-width', '500px')).toBe(true);
});
it("css-2 responsive için body tag'i ile min genişlik 300px ayarlanmış", () => {
expect(isPropertySetInCss(mediaQuery, 'body', 'min-width', '300px')).toBe(
true
);
});
it("css-3 menu-items class'ında istenen 3 özellik de tanımlanmış.", () => {
expect(
isPropertySetInCss(mediaQuery, '.menu-items', 'flex-direction', 'column')
).toBe(true);
expect(
isPropertySetInCss(mediaQuery, '.menu-items', 'align-items', 'stretch')
).toBe(true);
expect(isPropertySetInCss(mediaQuery, '.menu-items', 'gap', '0')).toBe(
true
);
});
it("css-4 gallery-section'daki image'ların genişliği 45% yapılmış", () => {
expect(
isPropertySetInCss(mediaQuery, '.gallery-sectionimg', 'width', '45%')
).toBe(true);
});
it("css-5 gallery-section'daki image'ların 5.sinden sonrakiler(n+5) display ile ekrandan kaldırılmış.", () => {
expect(
isPropertySetInCss(
mediaQuery,
'.gallery-sectionimg:nth-child(n+5)',
'display',
'none'
)
).toBe(true);
});
});