Skip to content

Commit

Permalink
Use node test runner
Browse files Browse the repository at this point in the history
  • Loading branch information
raub committed Oct 7, 2023
1 parent 6e983c6 commit 4ed54da
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 25 deletions.
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,8 @@
},
"scripts": {
"eslint": "eslint .",
"test": "jest --coverage=false --watch --config=conf/jest.json",
"test-ci": "jest --ci --runInBand --coverage=false --forceExit --detectOpenHandles --config=conf/jest.json",
"test-coverage": "rm -rf doc/jest && jest --coverage --silent --config=conf/jest.json"
"test": "node --test --watch",
"test-ci": "node --test"
},
"repository": {
"type": "git",
Expand Down
30 changes: 11 additions & 19 deletions test/index.test.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
'use strict';

const { init } = require('..');
const assert = require('node:assert').strict;
const { describe, it } = require('node:test');

const three = require('three');
const { init } = require('..');

const inited = init();
const {
gl, Document, Window, Image,
Brush, Cloud, Drawable, Lines, Points, Rect, Screen, Surface, Tris,
} = inited;

const three = {};

const staticClasses = {

Brush: {
create({ screen }) {
return new Brush({ screen });
},
props: ['size', 'pos', 'visible', 'color'],
methods: [],
},

Cloud: {
create({ screen }) {
const vertices = [];
Expand All @@ -36,15 +36,13 @@ const staticClasses = {
props: ['three', 'screen', 'mat', 'geo', 'mesh', 'visible'],
methods: [],
},

Drawable: {
create({ screen }) {
return new Drawable({ screen });
},
props: ['three', 'screen', 'mat', 'geo', 'mesh', 'z', 'visible', 'pos', 'color'],
methods: [],
},

Points: {
create({ screen }) {
const vertices = [];
Expand All @@ -60,7 +58,6 @@ const staticClasses = {
props: ['three', 'screen', 'mat', 'geo', 'mesh', 'visible'],
methods: [],
},

Lines: {
create({ screen }) {
const vertices = [];
Expand All @@ -76,7 +73,6 @@ const staticClasses = {
props: ['three', 'screen', 'mat', 'geo', 'mesh', 'visible'],
methods: [],
},

Tris: {
create({ screen }) {
const vertices = [];
Expand All @@ -92,15 +88,13 @@ const staticClasses = {
props: ['three', 'screen', 'mat', 'geo', 'mesh', 'visible'],
methods: [],
},

Rect: {
create({ screen }) {
return new Rect({ screen });
},
props: ['three', 'screen', 'mat', 'geo', 'mesh', 'visible'],
methods: [],
},

Screen: {
create() {
return new Screen({ three });
Expand All @@ -111,7 +105,6 @@ const staticClasses = {
],
methods: [],
},

Surface: {
create({ screen }) {
return new Surface({ screen });
Expand Down Expand Up @@ -151,17 +144,16 @@ const initedClasses = {
},
};


describe('Node.js 3D Core', () => {
it('exports an object', () => {
expect(typeof inited).toBe('object');
assert.strictEqual(typeof inited, 'object');
});

describe('Static classes', () => {
Object.keys(staticClasses).forEach(
(c) => {
it(`${c} is exported`, () => {
expect(typeof inited[c]).toBe('function');
assert.strictEqual(typeof inited[c], 'function');
});
}
);
Expand All @@ -173,18 +165,18 @@ describe('Node.js 3D Core', () => {
const instance = current.create({ screen });

it('can be created', () => {
expect(instance).toBeInstanceOf(inited[c]);
assert.strictEqual(instance instanceof inited[c], true);
});

current.props.forEach((prop) => {
it(`#${prop} property exposed`, () => {
expect(instance).toHaveProperty(prop);
assert.strictEqual(instance[prop] !== undefined, true);
});
});

current.methods.forEach((method) => {
it(`#${method}() method exposed`, () => {
expect(typeof instance[method]).toBe('function');
assert.strictEqual(typeof instance[method], 'function');
});
});
}));
Expand All @@ -194,7 +186,7 @@ describe('Node.js 3D Core', () => {
Object.keys(initedClasses).forEach(
(c) => {
it(`${c} is exported`, () => {
expect(typeof inited[c]).toBe('function');
assert.strictEqual(typeof inited[c], 'function');
});
}
);
Expand All @@ -204,7 +196,7 @@ describe('Node.js 3D Core', () => {
const instance = current.create();

it('can be created', () => {
expect(instance).toBeInstanceOf(inited[c]);
assert.strictEqual(instance instanceof inited[c], true);
});
}));
});
Expand Down
3 changes: 0 additions & 3 deletions test/setup.js

This file was deleted.

0 comments on commit 4ed54da

Please sign in to comment.