Skip to content

Commit 95a8da5

Browse files
committed
Add fixtures to jest tests.
1 parent a8ca644 commit 95a8da5

File tree

5 files changed

+102
-3
lines changed

5 files changed

+102
-3
lines changed

jest.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ module.exports = {
1010
moduleNameMapper: {
1111
'\\.(css|less|png|jpg|mp4|svg)$': '<rootDir>/tests/js/__mocks__/styleMock.js',
1212
'^app(.*)$': '<rootDir>/assets/js$1',
13+
'^tests(.*)$': '<rootDir>/tests/js$1',
1314
},
1415
modulePaths: ['<rootDir>/assets/js'],
1516
testMatch: ['<rootDir>/tests/js/**/*(*.)@(spec|test).(js|ts)?(x)'],

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
"webpack-cli": "^4.2.0"
4848
},
4949
"devDependencies": {
50+
"@testing-library/react": "^11.2.3",
5051
"@types/jest": "^26.0.19",
5152
"babel-jest": "^26.6.3",
5253
"jest": "^26.6.3"

tests/js/fixtures.ts

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import {Task, Project} from 'app/types';
2+
3+
export function makeTask(props?: Partial<Task>): Task {
4+
const defaults: Task = {
5+
id: 1,
6+
title: '',
7+
body: '',
8+
completed: false,
9+
due_on: null,
10+
day_order: 0,
11+
child_order: 0,
12+
subtask_count: 0,
13+
complete_subtask_count: 0,
14+
created: '',
15+
modified: '',
16+
project: makeProject(props?.project ?? {}),
17+
};
18+
return {
19+
...defaults,
20+
...props,
21+
};
22+
}
23+
24+
export function makeProject(props?: Partial<Project>): Project {
25+
const defaults: Project = {
26+
id: 1,
27+
name: 'Work',
28+
slug: 'work',
29+
color: '993399',
30+
favorite: false,
31+
archived: false,
32+
incomplete_task_count: 0,
33+
};
34+
return {
35+
...defaults,
36+
...props,
37+
};
38+
}

tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222
"outDir": "webroot/js",
2323
"baseUrl": ".",
2424
"paths": {
25-
"app/*": ["assets/js/*"]
25+
"app/*": ["assets/js/*"],
26+
"tests/*": ["tests/js/*"]
2627
}
2728
},
2829
"include": [

yarn.lock

Lines changed: 60 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -979,7 +979,15 @@
979979
"@babel/helper-validator-option" "^7.12.1"
980980
"@babel/plugin-transform-typescript" "^7.12.1"
981981

982-
"@babel/runtime@^7.12.1", "@babel/runtime@^7.2.0", "@babel/runtime@^7.4.4", "@babel/runtime@^7.5.5", "@babel/runtime@^7.7.2", "@babel/runtime@^7.8.4", "@babel/runtime@^7.8.7":
982+
"@babel/runtime-corejs3@^7.10.2":
983+
version "7.12.5"
984+
resolved "https://registry.yarnpkg.com/@babel/runtime-corejs3/-/runtime-corejs3-7.12.5.tgz#ffee91da0eb4c6dae080774e94ba606368e414f4"
985+
integrity sha512-roGr54CsTmNPPzZoCP1AmDXuBoNao7tnSA83TXTwt+UK5QVyh1DIJnrgYRPWKCF2flqZQXwa7Yr8v7VmLzF0YQ==
986+
dependencies:
987+
core-js-pure "^3.0.0"
988+
regenerator-runtime "^0.13.4"
989+
990+
"@babel/runtime@^7.10.2", "@babel/runtime@^7.12.1", "@babel/runtime@^7.12.5", "@babel/runtime@^7.2.0", "@babel/runtime@^7.4.4", "@babel/runtime@^7.5.5", "@babel/runtime@^7.7.2", "@babel/runtime@^7.8.4", "@babel/runtime@^7.8.7":
983991
version "7.12.5"
984992
resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.12.5.tgz#410e7e487441e1b360c29be715d870d9b985882e"
985993
integrity sha512-plcc+hbExy3McchJCEQG3knOsuh3HH+Prx1P6cLIkET/0dLuQDEnrT+s27Axgc9bqfsmNUNHfscgMUdBpC9xfg==
@@ -1371,6 +1379,33 @@
13711379
dependencies:
13721380
"@sinonjs/commons" "^1.7.0"
13731381

1382+
"@testing-library/dom@^7.28.1":
1383+
version "7.29.2"
1384+
resolved "https://registry.yarnpkg.com/@testing-library/dom/-/dom-7.29.2.tgz#6cba65d961d8b36d621a98caa8537444075fb42e"
1385+
integrity sha512-CBMELfyY1jKdtLcSRmEnZWRzRkCRVSNPTzhzrn8wY8OnzUo7Pe/W+HgLzt4TDnWIPYeusHBodf9wUjJF48kPmA==
1386+
dependencies:
1387+
"@babel/code-frame" "^7.10.4"
1388+
"@babel/runtime" "^7.12.5"
1389+
"@types/aria-query" "^4.2.0"
1390+
aria-query "^4.2.2"
1391+
chalk "^4.1.0"
1392+
dom-accessibility-api "^0.5.4"
1393+
lz-string "^1.4.4"
1394+
pretty-format "^26.6.2"
1395+
1396+
"@testing-library/react@^11.2.3":
1397+
version "11.2.3"
1398+
resolved "https://registry.yarnpkg.com/@testing-library/react/-/react-11.2.3.tgz#9971ede1c8465a231d7982eeca3c39fc362d5443"
1399+
integrity sha512-BirBUGPkTW28ULuCwIbYo0y2+0aavHczBT6N9r3LrsswEW3pg25l1wgoE7I8QBIy1upXWkwKpYdWY7NYYP0Bxw==
1400+
dependencies:
1401+
"@babel/runtime" "^7.12.5"
1402+
"@testing-library/dom" "^7.28.1"
1403+
1404+
"@types/aria-query@^4.2.0":
1405+
version "4.2.1"
1406+
resolved "https://registry.yarnpkg.com/@types/aria-query/-/aria-query-4.2.1.tgz#78b5433344e2f92e8b306c06a5622c50c245bf6b"
1407+
integrity sha512-S6oPal772qJZHoRZLFc/XoZW2gFvwXusYUmXPXkgxJLuEk2vOt7jc4Yo6z/vtI0EBkbPBVrJJ0B+prLIKiWqHg==
1408+
13741409
"@types/babel__core@^7.0.0", "@types/babel__core@^7.1.7":
13751410
version "7.1.12"
13761411
resolved "https://registry.yarnpkg.com/@types/babel__core/-/babel__core-7.1.12.tgz#4d8e9e51eb265552a7e4f1ff2219ab6133bdfb2d"
@@ -1929,6 +1964,14 @@ argparse@^1.0.7:
19291964
dependencies:
19301965
sprintf-js "~1.0.2"
19311966

1967+
aria-query@^4.2.2:
1968+
version "4.2.2"
1969+
resolved "https://registry.yarnpkg.com/aria-query/-/aria-query-4.2.2.tgz#0d2ca6c9aceb56b8977e9fed6aed7e15bbd2f83b"
1970+
integrity sha512-o/HelwhuKpTj/frsOsbNLNgnNGVIFsVP/SW2BSF14gVl7kAfMOJ6/8wUAUvG1R1NHKrfG+2sHZTu0yauT1qBrA==
1971+
dependencies:
1972+
"@babel/runtime" "^7.10.2"
1973+
"@babel/runtime-corejs3" "^7.10.2"
1974+
19321975
arity-n@^1.0.4:
19331976
version "1.0.4"
19341977
resolved "https://registry.yarnpkg.com/arity-n/-/arity-n-1.0.4.tgz#d9e76b11733e08569c0847ae7b39b2860b30b745"
@@ -2635,7 +2678,7 @@ chalk@^2.0.0, chalk@^2.3.0, chalk@^2.4.1, chalk@^2.4.2:
26352678
escape-string-regexp "^1.0.5"
26362679
supports-color "^5.3.0"
26372680

2638-
chalk@^4.0.0:
2681+
chalk@^4.0.0, chalk@^4.1.0:
26392682
version "4.1.0"
26402683
resolved "https://registry.yarnpkg.com/chalk/-/chalk-4.1.0.tgz#4e14870a618d9e2edd97dd8345fd9d9dc315646a"
26412684
integrity sha512-qwx12AxXe2Q5xQ43Ac//I6v5aXTipYrSESdOgzrN+9XjgEpyjpKuvSGaN4qE93f7TQTlerQQ8S+EQ0EyDoVL1A==
@@ -3025,6 +3068,11 @@ core-js-compat@^3.7.0:
30253068
browserslist "^4.15.0"
30263069
semver "7.0.0"
30273070

3071+
core-js-pure@^3.0.0:
3072+
version "3.8.2"
3073+
resolved "https://registry.yarnpkg.com/core-js-pure/-/core-js-pure-3.8.2.tgz#286f885c0dac1cdcd6d78397392abc25ddeca225"
3074+
integrity sha512-v6zfIQqL/pzTVAbZvYUozsxNfxcFb6Ks3ZfEbuneJl3FW9Jb8F6vLWB6f+qTmAu72msUdyb84V8d/yBFf7FNnw==
3075+
30283076
core-util-is@1.0.2, core-util-is@~1.0.0:
30293077
version "1.0.2"
30303078
resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7"
@@ -3562,6 +3610,11 @@ dns-txt@^2.0.2:
35623610
dependencies:
35633611
buffer-indexof "^1.0.0"
35643612

3613+
dom-accessibility-api@^0.5.4:
3614+
version "0.5.4"
3615+
resolved "https://registry.yarnpkg.com/dom-accessibility-api/-/dom-accessibility-api-0.5.4.tgz#b06d059cdd4a4ad9a79275f9d414a5c126241166"
3616+
integrity sha512-TvrjBckDy2c6v6RLxPv5QXOnU+SmF9nBII5621Ve5fu6Z/BDrENurBEvlC1f44lKEUVqOpK4w9E5Idc5/EgkLQ==
3617+
35653618
dom-helpers@^5.0.1:
35663619
version "5.2.0"
35673620
resolved "https://registry.yarnpkg.com/dom-helpers/-/dom-helpers-5.2.0.tgz#57fd054c5f8f34c52a3eeffdb7e7e93cd357d95b"
@@ -6077,6 +6130,11 @@ lru-cache@^6.0.0:
60776130
dependencies:
60786131
yallist "^4.0.0"
60796132

6133+
lz-string@^1.4.4:
6134+
version "1.4.4"
6135+
resolved "https://registry.yarnpkg.com/lz-string/-/lz-string-1.4.4.tgz#c0d8eaf36059f705796e1e344811cf4c498d3a26"
6136+
integrity sha1-wNjq82BZ9wV5bh40SBHPTEmNOiY=
6137+
60806138
make-dir@^1.0.0:
60816139
version "1.3.0"
60826140
resolved "https://registry.yarnpkg.com/make-dir/-/make-dir-1.3.0.tgz#79c1033b80515bd6d24ec9933e860ca75ee27f0c"

0 commit comments

Comments
 (0)