Skip to content
This repository was archived by the owner on Jun 24, 2024. It is now read-only.

Commit c93bc3b

Browse files
author
Walker
committed
Add assertion expectations, fix tests
1 parent 3998f15 commit c93bc3b

File tree

1 file changed

+22
-4
lines changed

1 file changed

+22
-4
lines changed

test/writer.test.js

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ const { identifyCssModule, bundleCssModule } = require('../lib/util.js');
88
const Writer = require('..');
99

1010
test('identifyCssModule(filePath)', async () => {
11+
expect.assertions(1);
1112
const filePath = path.join(__dirname, 'test-assets/my-module-1/main.css');
1213
const fileRef = 'my-module-1/main.css';
1314

@@ -23,6 +24,7 @@ test('identifyCssModule(filePath)', async () => {
2324
});
2425

2526
test('identifyCssModule(filePath) css in nested directory', async () => {
27+
expect.assertions(1);
2628
const filePath = path.join(__dirname, 'test-assets/my-module-2/css/main.css');
2729
const fileRef = 'my-module-2/css/main.css';
2830

@@ -38,6 +40,7 @@ test('identifyCssModule(filePath) css in nested directory', async () => {
3840
});
3941

4042
test('bundleCssModule(filePath)', async () => {
43+
expect.assertions(3);
4144
const filePath = path.join(__dirname, 'test-assets/my-module-3/css/main.css');
4245

4346
const result = await bundleCssModule(filePath);
@@ -47,7 +50,8 @@ test('bundleCssModule(filePath)', async () => {
4750
expect(result).toMatch('dep/main.css');
4851
});
4952

50-
test('new Writer(filePath)', () => {
53+
test('new Writer(filePath)', done => {
54+
expect.assertions(2);
5155
const filePath = path.join(__dirname, 'test-assets/my-module-1/main.css');
5256
const fileRef = 'my-module-1/main.css';
5357

@@ -63,18 +67,21 @@ test('new Writer(filePath)', () => {
6367
const result2 = items[1];
6468
expect(result1.id).toBe(hasher(`my-module-1|1.0.1|${fileRef}`));
6569
expect(result2).toBeFalsy();
70+
done();
6671
});
6772
});
6873

6974
test('new Writer(filePath) relative paths throw error', () => {
75+
expect.assertions(1);
7076
const filePath = './test-assets/my-module-1/main.css';
7177

7278
const result = () => new Writer(filePath);
7379

7480
expect(result).toThrow();
7581
});
7682

77-
test('new Writer([filePath])', () => {
83+
test('new Writer([filePath])', done => {
84+
expect.assertions(2);
7885
const filePath = path.join(__dirname, 'test-assets/my-module-1/main.css');
7986
const fileRef = 'my-module-1/main.css';
8087

@@ -90,10 +97,12 @@ test('new Writer([filePath])', () => {
9097
const result2 = items[1];
9198
expect(result1.id).toBe(hasher(`my-module-1|1.0.1|${fileRef}`));
9299
expect(result2).toBeFalsy();
100+
done();
93101
});
94102
});
95103

96-
test('Writer processes @import statements', () => {
104+
test('Writer processes @import statements', done => {
105+
expect.assertions(5);
97106
const filePath = path.join(__dirname, 'test-assets/my-module-3/css/main.css');
98107
const fileRef = 'my-module-3/css/main.css';
99108

@@ -113,10 +122,12 @@ test('Writer processes @import statements', () => {
113122
expect(result1.content).toMatch('my-module-3/dep.css');
114123
expect(result1.content).toMatch('dep/main.css');
115124
expect(result2).toBeFalsy();
125+
done();
116126
});
117127
});
118128

119-
test('new Writer([filePath1, filePath2]) ensures correct order', () => {
129+
test('new Writer([filePath1, filePath2]) ensures correct order', done => {
130+
expect.assertions(3);
120131
const filePath1 = path.join(__dirname, 'test-assets/my-module-1/main.css');
121132
const fileRef1 = 'my-module-1/main.css';
122133
const filePath2 = path.join(__dirname, 'test-assets/my-module-2/css/main.css');
@@ -137,10 +148,12 @@ test('new Writer([filePath1, filePath2]) ensures correct order', () => {
137148
expect(result1.id).toBe(hasher(`my-module-1|1.0.1|${fileRef1}`));
138149
expect(result2.id).toBe(hasher(`my-module-2|1.0.1|${fileRef2}`));
139150
expect(result3).toBeFalsy();
151+
done();
140152
});
141153
});
142154

143155
test('new Writer([filePath]) ensures filePath[] is not null', () => {
156+
expect.assertions(1);
144157
const filePath = null;
145158

146159
const result = () => new Writer(filePath);
@@ -149,6 +162,7 @@ test('new Writer([filePath]) ensures filePath[] is not null', () => {
149162
});
150163

151164
test('new Writer([filePath]) ensures filePath[] is not a number', () => {
165+
expect.assertions(1);
152166
const filePath = 2;
153167

154168
const result = () => new Writer(filePath);
@@ -157,6 +171,7 @@ test('new Writer([filePath]) ensures filePath[] is not a number', () => {
157171
});
158172

159173
test('new Writer([filePath]) ensures filePath is not an object', () => {
174+
expect.assertions(1);
160175
const filePath = {};
161176

162177
const result = () => new Writer(filePath);
@@ -165,6 +180,7 @@ test('new Writer([filePath]) ensures filePath is not an object', () => {
165180
});
166181

167182
test('new Writer([filePath]) ensures filePath[] is an array of strings', () => {
183+
expect.assertions(1);
168184
const filePath = null;
169185

170186
const result = () => new Writer([filePath]);
@@ -173,6 +189,7 @@ test('new Writer([filePath]) ensures filePath[] is an array of strings', () => {
173189
});
174190

175191
test('new Writer([filePath]) ensures valid filePath provided', () => {
192+
expect.assertions(1);
176193
const filePath = 'fake.css';
177194

178195
const result = () => new Writer(filePath);
@@ -181,6 +198,7 @@ test('new Writer([filePath]) ensures valid filePath provided', () => {
181198
});
182199

183200
test('new Writer([filePath]) ensures valid filePaths provided in array', () => {
201+
expect.assertions(1);
184202
const filePath = 'fake.css';
185203

186204
const result = () => new Writer([filePath]);

0 commit comments

Comments
 (0)