Skip to content

Commit c4bd533

Browse files
committed
test: Improve isObjectType tests with Symbol.toStringTag mock
1 parent 65bc70d commit c4bd533

File tree

19 files changed

+76
-105
lines changed

19 files changed

+76
-105
lines changed

integrationTests/dev-bun/test.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
import assert from 'assert';
22
import { isObjectType } from 'graphql';
33

4-
class FakeGraphQLObjectType {
5-
constructor() {
6-
this.name = 'Fake';
4+
class GraphQLObjectType {
5+
get [Symbol.toStringTag]() {
6+
return 'GraphQLObjectType';
77
}
88
}
99

10-
const fakeInstance = new FakeGraphQLObjectType();
11-
1210
try {
13-
isObjectType(fakeInstance);
11+
isObjectType(new GraphQLObjectType());
1412
assert.fail('Expected isObjectType to throw an error in Bun development mode.');
1513
} catch (error) {
1614
assert.ok(

integrationTests/dev-deno/test.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
import assert from 'assert';
22
import { isObjectType } from 'graphql';
33

4-
class FakeGraphQLObjectType {
5-
constructor() {
6-
this.name = 'Fake';
4+
class GraphQLObjectType {
5+
get [Symbol.toStringTag]() {
6+
return 'GraphQLObjectType';
77
}
88
}
99

10-
const fakeInstance = new FakeGraphQLObjectType();
11-
1210
try {
13-
isObjectType(fakeInstance);
11+
isObjectType(new GraphQLObjectType());
1412
assert.fail('Expected isObjectType to throw an error in Deno development mode.');
1513
} catch (error) {
1614
assert.ok(

integrationTests/dev-esbuild/src/index.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
import assert from 'assert';
22
import { isObjectType } from 'graphql';
33

4-
class FakeGraphQLObjectType {
5-
constructor() {
6-
this.name = 'Fake';
4+
class GraphQLObjectType {
5+
get [Symbol.toStringTag]() {
6+
return 'GraphQLObjectType';
77
}
88
}
99

10-
const fakeInstance = new FakeGraphQLObjectType();
11-
1210
try {
13-
isObjectType(fakeInstance);
11+
isObjectType(new GraphQLObjectType());
1412
assert.fail('Expected isObjectType to throw an error in esbuild development mode.');
1513
} catch (error) {
1614
assert.ok(

integrationTests/dev-nextjs/test.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
import assert from 'assert';
22
import { isObjectType } from 'graphql';
33

4-
class FakeGraphQLObjectType {
5-
constructor() {
6-
this.name = 'Fake';
4+
class GraphQLObjectType {
5+
get [Symbol.toStringTag]() {
6+
return 'GraphQLObjectType';
77
}
88
}
99

10-
const fakeInstance = new FakeGraphQLObjectType();
11-
1210
try {
13-
isObjectType(fakeInstance);
11+
isObjectType(new GraphQLObjectType());
1412
assert.fail('Expected isObjectType to throw an error in Next.js development mode.');
1513
} catch (error) {
1614
assert.ok(

integrationTests/dev-node-explicit/test.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
import assert from 'assert';
22
import { isObjectType } from 'graphql';
33

4-
class FakeGraphQLObjectType {
5-
constructor() {
6-
this.name = 'Fake';
4+
class GraphQLObjectType {
5+
get [Symbol.toStringTag]() {
6+
return 'GraphQLObjectType';
77
}
88
}
99

10-
const fakeInstance = new FakeGraphQLObjectType();
11-
1210
try {
13-
isObjectType(fakeInstance);
11+
isObjectType(new GraphQLObjectType());
1412
assert.fail('Expected isObjectType to throw an error in Node.js explicit development mode.');
1513
} catch (error) {
1614
assert.ok(

integrationTests/dev-node-implicit/test.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
import assert from 'assert';
22
import { isObjectType } from 'graphql';
33

4-
class FakeGraphQLObjectType {
5-
constructor() {
6-
this.name = 'Fake';
4+
class GraphQLObjectType {
5+
get [Symbol.toStringTag]() {
6+
return 'GraphQLObjectType';
77
}
88
}
99

10-
const fakeInstance = new FakeGraphQLObjectType();
11-
1210
try {
13-
isObjectType(fakeInstance);
11+
isObjectType(new GraphQLObjectType());
1412
assert.fail('Expected isObjectType to throw an error in Node.js implicit development mode.');
1513
} catch (error) {
1614
assert.ok(

integrationTests/dev-rollup/src/index.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
import assert from 'assert';
22
import { isObjectType } from 'graphql';
33

4-
class FakeGraphQLObjectType {
5-
constructor() {
6-
this.name = 'Fake';
4+
class GraphQLObjectType {
5+
get [Symbol.toStringTag]() {
6+
return 'GraphQLObjectType';
77
}
88
}
99

10-
const fakeInstance = new FakeGraphQLObjectType();
11-
1210
try {
13-
isObjectType(fakeInstance);
11+
isObjectType(new GraphQLObjectType());
1412
assert.fail('Expected isObjectType to throw an error in Rollup development mode.');
1513
} catch (error) {
1614
assert.ok(

integrationTests/dev-swc/src/index.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
import assert from 'assert';
22
import { isObjectType } from 'graphql';
33

4-
class FakeGraphQLObjectType {
5-
constructor() {
6-
this.name = 'Fake';
4+
class GraphQLObjectType {
5+
get [Symbol.toStringTag]() {
6+
return 'GraphQLObjectType';
77
}
88
}
99

10-
const fakeInstance = new FakeGraphQLObjectType();
11-
1210
try {
13-
isObjectType(fakeInstance);
11+
isObjectType(new GraphQLObjectType());
1412
assert.fail('Expected isObjectType to throw an error in SWC development mode.');
1513
} catch (error) {
1614
assert.ok(

integrationTests/dev-vite/src/index.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
import assert from 'assert';
22
import { isObjectType } from 'graphql';
33

4-
class FakeGraphQLObjectType {
5-
constructor() {
6-
this.name = 'Fake';
4+
class GraphQLObjectType {
5+
get [Symbol.toStringTag]() {
6+
return 'GraphQLObjectType';
77
}
88
}
99

10-
const fakeInstance = new FakeGraphQLObjectType();
11-
1210
try {
13-
isObjectType(fakeInstance);
11+
isObjectType(new GraphQLObjectType());
1412
assert.fail('Expected isObjectType to throw an error in Vite development mode.');
1513
} catch (error) {
1614
assert.ok(

integrationTests/dev-webpack/src/index.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
import assert from 'assert';
22
import { isObjectType } from 'graphql';
33

4-
class FakeGraphQLObjectType {
5-
constructor() {
6-
this.name = 'Fake';
4+
class GraphQLObjectType {
5+
get [Symbol.toStringTag]() {
6+
return 'GraphQLObjectType';
77
}
88
}
99

10-
const fakeInstance = new FakeGraphQLObjectType();
11-
1210
try {
13-
isObjectType(fakeInstance);
11+
isObjectType(new GraphQLObjectType());
1412
assert.fail('Expected isObjectType to throw an error in Webpack development mode.');
1513
} catch (error) {
1614
assert.ok(

integrationTests/prod-bun/test.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
import assert from 'assert';
22
import { isObjectType } from 'graphql';
33

4-
class FakeGraphQLObjectType {
5-
constructor() {
6-
this.name = 'Fake';
4+
class GraphQLObjectType {
5+
get [Symbol.toStringTag]() {
6+
return 'GraphQLObjectType';
77
}
88
}
99

10-
const fakeInstance = new FakeGraphQLObjectType();
11-
const result = isObjectType(fakeInstance);
10+
const result = isObjectType(new GraphQLObjectType());
1211
assert.strictEqual(result, false, 'isObjectType should return false in Bun production mode.');

integrationTests/prod-deno/test.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
import assert from 'assert';
22
import { isObjectType } from 'graphql';
33

4-
class FakeGraphQLObjectType {
5-
constructor() {
6-
this.name = 'Fake';
4+
class GraphQLObjectType {
5+
get [Symbol.toStringTag]() {
6+
return 'GraphQLObjectType';
77
}
88
}
99

10-
const fakeInstance = new FakeGraphQLObjectType();
11-
const result = isObjectType(fakeInstance);
10+
const result = isObjectType(new GraphQLObjectType());
1211
assert.strictEqual(result, false, 'isObjectType should return false in Deno production mode.');
Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
import assert from 'assert';
22
import { isObjectType } from 'graphql';
33

4-
class FakeGraphQLObjectType {
5-
constructor() {
6-
this.name = 'Fake';
4+
class GraphQLObjectType {
5+
get [Symbol.toStringTag]() {
6+
return 'GraphQLObjectType';
77
}
88
}
99

10-
const fakeInstance = new FakeGraphQLObjectType();
11-
const result = isObjectType(fakeInstance);
10+
const result = isObjectType(new GraphQLObjectType());
1211
assert.strictEqual(result, false, 'isObjectType should return false in esbuild production mode.');

integrationTests/prod-nextjs/test.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
import assert from 'assert';
22
import { isObjectType } from 'graphql';
33

4-
class FakeGraphQLObjectType {
5-
constructor() {
6-
this.name = 'Fake';
4+
class GraphQLObjectType {
5+
get [Symbol.toStringTag]() {
6+
return 'GraphQLObjectType';
77
}
88
}
99

10-
const fakeInstance = new FakeGraphQLObjectType();
11-
const result = isObjectType(fakeInstance);
10+
const result = isObjectType(new GraphQLObjectType());
1211
assert.strictEqual(result, false, 'isObjectType should return false in Next.js production mode.');

integrationTests/prod-node/test.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
import assert from 'assert';
22
import { isObjectType } from 'graphql';
33

4-
class FakeGraphQLObjectType {
5-
constructor() {
6-
this.name = 'Fake';
4+
class GraphQLObjectType {
5+
get [Symbol.toStringTag]() {
6+
return 'GraphQLObjectType';
77
}
88
}
99

10-
const fakeInstance = new FakeGraphQLObjectType();
11-
const result = isObjectType(fakeInstance);
10+
const result = isObjectType(new GraphQLObjectType());
1211
assert.strictEqual(result, false, 'isObjectType should return false in Node.js production mode.');
Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
import assert from 'assert';
22
import { isObjectType } from 'graphql';
33

4-
class FakeGraphQLObjectType {
5-
constructor() {
6-
this.name = 'Fake';
4+
class GraphQLObjectType {
5+
get [Symbol.toStringTag]() {
6+
return 'GraphQLObjectType';
77
}
88
}
99

10-
const fakeInstance = new FakeGraphQLObjectType();
11-
const result = isObjectType(fakeInstance);
10+
const result = isObjectType(new GraphQLObjectType());
1211
assert.strictEqual(result, false, 'isObjectType should return false in Rollup production mode.');
Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
import assert from 'assert';
22
import { isObjectType } from 'graphql';
33

4-
class FakeGraphQLObjectType {
5-
constructor() {
6-
this.name = 'Fake';
4+
class GraphQLObjectType {
5+
get [Symbol.toStringTag]() {
6+
return 'GraphQLObjectType';
77
}
88
}
99

10-
const fakeInstance = new FakeGraphQLObjectType();
11-
const result = isObjectType(fakeInstance);
10+
const result = isObjectType(new GraphQLObjectType());
1211
assert.strictEqual(result, false, 'isObjectType should return false in SWC production mode.');
Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
import assert from 'assert';
22
import { isObjectType } from 'graphql';
33

4-
class FakeGraphQLObjectType {
5-
constructor() {
6-
this.name = 'Fake';
4+
class GraphQLObjectType {
5+
get [Symbol.toStringTag]() {
6+
return 'GraphQLObjectType';
77
}
88
}
99

10-
const fakeInstance = new FakeGraphQLObjectType();
11-
const result = isObjectType(fakeInstance);
10+
const result = isObjectType(new GraphQLObjectType());
1211
assert.strictEqual(result, false, 'isObjectType should return false in Vite production mode.');
Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
import assert from 'assert';
22
import { isObjectType } from 'graphql';
33

4-
class FakeGraphQLObjectType {
5-
constructor() {
6-
this.name = 'Fake';
4+
class GraphQLObjectType {
5+
get [Symbol.toStringTag]() {
6+
return 'GraphQLObjectType';
77
}
88
}
99

10-
const fakeInstance = new FakeGraphQLObjectType();
11-
const result = isObjectType(fakeInstance);
10+
const result = isObjectType(new GraphQLObjectType());
1211
assert.strictEqual(result, false, 'isObjectType should return false in Webpack production mode.');

0 commit comments

Comments
 (0)