Skip to content

Commit c6774f4

Browse files
committedMar 25, 2025
chore: add class coverage to docs tests
1 parent 21dbdde commit c6774f4

File tree

2 files changed

+122
-0
lines changed

2 files changed

+122
-0
lines changed
 

‎tests/docs/fixtures/expected.js

+93
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,99 @@ module.exports = {
3030
'@warp-drive/schema-record',
3131
'ember-data-overview',
3232
],
33+
classes: [
34+
'(private) @ember-data/debug InspectorDataAdapter',
35+
'(private) @ember-data/model PromiseBelongsTo',
36+
'(public) @ember-data/adapter Adapter',
37+
'(public) @ember-data/adapter BuildURLMixin',
38+
'(public) @ember-data/adapter/error AbortError',
39+
'(public) @ember-data/adapter/error AdapterError',
40+
'(public) @ember-data/adapter/error ConflictError',
41+
'(public) @ember-data/adapter/error ForbiddenError',
42+
'(public) @ember-data/adapter/error InvalidError',
43+
'(public) @ember-data/adapter/error NotFoundError',
44+
'(public) @ember-data/adapter/error ServerError',
45+
'(public) @ember-data/adapter/error TimeoutError',
46+
'(public) @ember-data/adapter/error UnauthorizedError',
47+
'(public) @ember-data/adapter/json-api JSONAPIAdapter',
48+
'(public) @ember-data/adapter/rest RESTAdapter',
49+
'(public) @ember-data/experimental-preview-types <Interface> Adapter',
50+
'(public) @ember-data/experimental-preview-types <Interface> Cache',
51+
'(public) @ember-data/experimental-preview-types <Interface> Serializer',
52+
'(public) @ember-data/json-api Cache',
53+
'(public) @ember-data/legacy-compat SnapshotRecordArray',
54+
'(public) @ember-data/model BelongsToReference',
55+
'(public) @ember-data/model Errors',
56+
'(public) @ember-data/model HasManyReference',
57+
'(public) @ember-data/model Model',
58+
'(public) @ember-data/model PromiseManyArray',
59+
'(public) @ember-data/request <Interface> CacheHandler',
60+
'(public) @ember-data/request <Interface> Handler',
61+
'(public) @ember-data/request Future',
62+
'(public) @ember-data/request RequestManager',
63+
'(public) @ember-data/request-utils CachePolicy',
64+
'(public) @ember-data/request/fetch Fetch',
65+
'(public) @ember-data/serializer BooleanTransform',
66+
'(public) @ember-data/serializer DateTransform',
67+
'(public) @ember-data/serializer NumberTransform',
68+
'(public) @ember-data/serializer Serializer',
69+
'(public) @ember-data/serializer StringTransform',
70+
'(public) @ember-data/serializer Transform',
71+
'(public) @ember-data/serializer/json JSONSerializer',
72+
'(public) @ember-data/serializer/json-api JSONAPISerializer',
73+
'(public) @ember-data/serializer/rest EmbeddedRecordsMixin',
74+
'(public) @ember-data/serializer/rest RESTSerializer',
75+
'(public) @ember-data/store <Interface> CachePolicy',
76+
'(public) @ember-data/store <Interface> SchemaService',
77+
'(public) @ember-data/store CacheCapabilitiesManager',
78+
'(public) @ember-data/store CacheManager',
79+
'(public) @ember-data/store Document',
80+
'(public) @ember-data/store IdentifierCache',
81+
'(public) @ember-data/store ManyArray',
82+
'(public) @ember-data/store NotificationManager',
83+
'(public) @ember-data/store RecordArray',
84+
'(public) @ember-data/store RecordReference',
85+
'(public) @ember-data/store RequestStateService',
86+
'(public) @ember-data/store Snapshot',
87+
'(public) @ember-data/store StableRecordIdentifier',
88+
'(public) @ember-data/store Store',
89+
'(public) @warp-drive/build-config CanaryFeatures',
90+
'(public) @warp-drive/build-config CurrentDeprecations',
91+
'(public) @warp-drive/build-config DebugLogging',
92+
'(public) @warp-drive/core-types <Type> ArrayField',
93+
'(public) @warp-drive/core-types <Type> CollectionField',
94+
'(public) @warp-drive/core-types <Type> DerivedField',
95+
'(public) @warp-drive/core-types <Type> FieldSchema',
96+
'(public) @warp-drive/core-types <Type> GenericField',
97+
'(public) @warp-drive/core-types <Type> HashField',
98+
'(public) @warp-drive/core-types <Type> IdentityField',
99+
'(public) @warp-drive/core-types <Type> LegacyAliasField',
100+
'(public) @warp-drive/core-types <Type> LegacyAttributeField',
101+
'(public) @warp-drive/core-types <Type> LegacyBelongsToField',
102+
'(public) @warp-drive/core-types <Type> LegacyHasManyField',
103+
'(public) @warp-drive/core-types <Type> LegacyModeFieldSchema',
104+
'(public) @warp-drive/core-types <Type> LegacyResourceSchema',
105+
'(public) @warp-drive/core-types <Type> LinksModeBelongsToField',
106+
'(public) @warp-drive/core-types <Type> LinksModeHasManyField',
107+
'(public) @warp-drive/core-types <Type> LocalField',
108+
'(public) @warp-drive/core-types <Type> ObjectAliasField',
109+
'(public) @warp-drive/core-types <Type> ObjectField',
110+
'(public) @warp-drive/core-types <Type> ObjectFieldSchema',
111+
'(public) @warp-drive/core-types <Type> ObjectSchema',
112+
'(public) @warp-drive/core-types <Type> PolarisAliasField',
113+
'(public) @warp-drive/core-types <Type> PolarisModeFieldSchema',
114+
'(public) @warp-drive/core-types <Type> PolarisResourceSchema',
115+
'(public) @warp-drive/core-types <Type> ResourceField',
116+
'(public) @warp-drive/core-types <Type> SchemaArrayField',
117+
'(public) @warp-drive/core-types <Type> SchemaObjectField',
118+
'(public) @warp-drive/ember <Await />',
119+
'(public) @warp-drive/ember <Request />',
120+
'(public) @warp-drive/ember <Throw />',
121+
'(public) @warp-drive/ember PromiseState',
122+
'(public) @warp-drive/ember RequestLoadingState',
123+
'(public) @warp-drive/ember RequestState',
124+
'(public) @warp-drive/schema-record SchemaService',
125+
],
33126
classitems: [
34127
'(public) @warp-drive/core-types <Type> LegacyResourceSchema#fields',
35128
'(public) @warp-drive/core-types <Type> LegacyResourceSchema#identity',

‎tests/docs/index.js

+29
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,24 @@ QUnit.module('Docs coverage', function (hooks) {
4848
});
4949

5050
QUnit.module('classes', function (hooks) {
51+
const docsClasses = new Set(
52+
Object.keys(docs.classes)
53+
.map((className) => {
54+
const def = docs.classes[className];
55+
return className === def.module ? false : `(${def.access}) ${def.module ? `${def.module}` : ''} ${def.name}`;
56+
})
57+
.filter(Boolean)
58+
);
59+
const expectedClasses = new Set(expected.classes);
60+
5161
Object.keys(docs.classes).forEach((className) => {
5262
const def = docs.classes[className];
63+
64+
// Module main declarations are included in the docs as classes
5365
if (className === def.module) {
5466
return;
5567
}
68+
5669
test(`Class ${className} is documented correctly at ${linkItem(def)}`, function (assert) {
5770
assert.ok(docs.files[def.file], `${className} has a file`);
5871
assert.true(
@@ -65,6 +78,22 @@ QUnit.module('Docs coverage', function (hooks) {
6578
}
6679
});
6780
});
81+
82+
test('No missing classes', function (assert) {
83+
const missing = setDifference(expectedClasses, docsClasses);
84+
assert.emptySet(
85+
missing,
86+
'If you intentionally removed a public API class, please udpate tests/docs/expected.js. Otherwise, documentation is missing, incorrectly formatted, or in a directory that is not watched by yuidoc. All files containing documentation must have a yuidoc class declaration.'
87+
);
88+
});
89+
90+
test('No extraneous classes', function (assert) {
91+
const missing = setDifference(docsClasses, expectedClasses);
92+
assert.emptySet(
93+
missing,
94+
'If you intentionally removed a public API class, please udpate tests/docs/expected.js. Otherwise, documentation is missing, incorrectly formatted, or in a directory that is not watched by yuidoc. All files containing documentation must have a yuidoc class declaration.'
95+
);
96+
});
6897
});
6998

7099
QUnit.module('classitems', function (hooks) {

0 commit comments

Comments
 (0)